You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am looking for a way to move the cursor into a completed suggestion.
For example, if I type p and it completes to play(""), I would like the cursor to be positioned right after the first ".
I tried adding an ANSI escape sequence \033[2D (move cursor back 2x) but it is not being interpreted. An alternative could be to have a post complete func and a way to tell the *State that a cursor move is requested (programmatic CtrlB).
Before working on such a feature, I would like to have some feedback on this.
The last time we needed more features, we upgraded Completer with WordCompleter. This time, it probably makes sense to upgrade WordCompleter to PosCompleter
Something like
typeWordAndPosstruct {
Wordstring// completion stringPosint// position of cursor within completion string
}
typePosCompleterfunc(linestring, posint) (headstring, completions []WordAndPos, tailstring)
yes, I like this proposal. Finding a good name is always a challenge.
Maybe to generalise this, instead of returning a Pos int, we could have a CursorInstruction that be used to do:
"Move word back" and "set to end" are redundant when you have "set position". I especially want to avoid things like "move word back" when "word" is so poorly defined (and subject to change; See #113 for discussion)
liner isn't a text editor. I try to keep it as close to bash as possible. Unless bash has selections that I'm not aware of (which is possible, bash has lots of features that I'm not aware of) "create a selection" sounds like a feature that liner won't ever have.
I don't know if I like that more or less than PosCompleter. As they say, there are only two hard things in programming: Naming, Caching, and off-by-one errors.
You're doing the work, I'll let you choose the name (within reason).
Activity
peterh commentedon Mar 22, 2020
The last time we needed more features, we upgraded
CompleterwithWordCompleter. This time, it probably makes sense to upgradeWordCompletertoPosCompleterSomething like
(except with a better name than WordAndPos)
Thoughts?
emicklei commentedon Mar 23, 2020
yes, I like this proposal. Finding a good name is always a challenge.
Maybe to generalise this, instead of returning a Pos int, we could have a CursorInstruction that be used to do:
peterh commentedon Mar 24, 2020
"Move word back" and "set to end" are redundant when you have "set position". I especially want to avoid things like "move word back" when "word" is so poorly defined (and subject to change; See #113 for discussion)
liner isn't a text editor. I try to keep it as close to bash as possible. Unless bash has selections that I'm not aware of (which is possible, bash has lots of features that I'm not aware of) "create a selection" sounds like a feature that liner won't ever have.
emicklei commentedon Mar 24, 2020
fair enough. let's keep it simple. Suggestion:
Rationale: putting the cursor "in" the completed word is for the purpose of editing it after completion
peterh commentedon Mar 26, 2020
I don't know if I like that more or less than PosCompleter. As they say, there are only two hard things in programming: Naming, Caching, and off-by-one errors.
You're doing the work, I'll let you choose the name (within reason).
emicklei commentedon Mar 29, 2020
work in progress https://github.com/emicklei/liner/tree/poscomplete