Comments (9)
turns out each suggestion already includes the range in question.
so a base implementation does the trick
from reedline.
I'm up for whatever. BTW - I've never really liked Levenstein completions. I always thought alphabetical was better.
from reedline.
Seems plausible but sounds like it would be a breaking api change. Not that we're against that but seems like it may be tricky to retrofit in nushell. Maybe I'm wrong?
from reedline.
i guess we could make a seperate function for this then, but i feel like this just makes things unnecessarily complicated
But if we would do that, then there wont be any breaking changes
Edit: actually i think having a seperate function would probably be the better way to go
from reedline.
Separate function sounds great. If you put a //TODO in there around the function, to sometime consolidate functions, we can decide at a later point how important it is and if it's worth a breaking change. Thanks for bringing up this topic.
from reedline.
to make this function "optional" then
should i have a default implementation that panics or returns default values, when its not explicitly implemented?
something like this
pub trait Completer: Send {
/// the action that will take the line and position and convert it to a vector of completions, which include the
/// span to replace and the contents of that replacement
fn complete(&mut self, line: &str, pos: usize) -> Vec<Suggestion>;
/// complete, but also return the index of the start of the string being completed
fn complete_with_start(&mut self, line: &str, pos: usize) -> (Vec<Suggestion>, usize) {
panic!("Not implemented")
}
...
}
from reedline.
Is it possible to have complete_with_start call complete if complete_with_start isn't implemented? Kind of uses the default implementation of complete if complete_with_start isn't implemented.
from reedline.
@fdncred that would only work if we can assume that the suggestions starts with the last part of the line. then the start position can be calculated from that. otherwise (if the completer uses a different way, like levensthein distance of the last word or so)
then this will return a wrong value
but you could also return a default position like 0, but i think it would be better to panic then returning something potentially wrong
from reedline.
all of the current menus that support this can just do this
impl Completer for DefaultCompleter {
fn complete(&mut self, line: &str, pos: usize) -> Vec<Suggestion> {
complete_with_start(&mut self, line: &str, pos: usize).0
}
fn complete_with_start(&mut self, line: &str, pos: usize) -> (Vec<Suggestion>, usize) {
...
}
...
}
from reedline.
Related Issues (20)
- Tab keybind doesnt work with modifiers HOT 5
- [QUESTION]: can I disable the indicator HOT 2
- `Move(Big)WordRightEnd` is off-by-1 in insert mode HOT 1
- New actions to cancel menu & accept-and-hold
- Index out of bounds HOT 8
- 0.30.0 (Nu 0.91.0) does not respect cursor position after host cmd exec in a keybinding HOT 10
- Prefix history search broken in vi-mode HOT 5
- `columnar_menu` panics on non-ASCII characters in directory
- Mouse controls HOT 1
- vi keybinds are wrong and/or inconsistent with readline HOT 2
- Modal Menus
- Default keybind for "newline" HOT 1
- Column menu spaces don't respect special characters (accents, emojis...)
- Cursor slowdown when pressing left/right arrows and there is a lot of text in the prompt HOT 2
- analog to inputrc for programs using reedline HOT 1
- progress in recommended phrase by one word-bound HOT 1
- Problem with powershell HOT 2
- `oh-my-posh` left and right prompt are not drawn at the same level HOT 3
- Panic in IdeMenu::create_value_string HOT 1
- Command history additional alternative to sync_on_enter HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reedline.