This adds the (optional) prompt key to the return from getbufinfo() in order to see the effective prompt text for a prompt buffer.
This is useful when writing an omnifunc for prompt buffers, i.e. you can find the real text being entered with something like:
let line = getline( line( '.' ) )[ len( getbufinfo( '%' )[ 0 ].prompt ) : ]
This means that you don't have to know a-priori what the prompt will be and/or don't need to find a way to push this into your omnifunc callback.
https://github.com/vim/vim/pull/6851
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.![]()
This adds the (optional)
promptkey to the return fromgetbufinfo()in order to see the effective prompt text for a prompt buffer.This is useful when writing an
omnifuncfor prompt buffers, i.e. you can find the real text being entered with something like:let line = getline( line( '.' ) )[ len( getbufinfo( '%' )[ 0 ].prompt ) : ]This means that you don't have to know a-priori what the prompt will be and/or don't need to find a way to push this into your omnifunc callback.
Merging #6851 into master will increase coverage by
0.00%.
The diff coverage is100.00%.
@@ Coverage Diff @@ ## master #6851 +/- ## ======================================= Coverage 88.50% 88.51% ======================================= Files 147 147 Lines 160916 160920 +4 ======================================= + Hits 142423 142441 +18 + Misses 18493 18479 -14
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/edit.c | 92.31% <100.00%> (+<0.01%) |
⬆️ |
| src/evalbuffer.c | 96.29% <100.00%> (+0.01%) |
⬆️ |
| src/netbeans.c | 76.07% <0.00%> (-0.23%) |
⬇️ |
| src/gui.c | 63.30% <0.00%> (-0.10%) |
⬇️ |
| src/terminal.c | 91.02% <0.00%> (ø) |
|
| src/channel.c | 89.83% <0.00%> (+0.03%) |
⬆️ |
| src/gui_gtk_x11.c | 58.73% <0.00%> (+0.04%) |
⬆️ |
| src/sign.c | 95.03% <0.00%> (+0.08%) |
⬆️ |
| src/search.c | 91.43% <0.00%> (+0.10%) |
⬆️ |
| src/gui_gtk.c | 31.71% <0.00%> (+0.27%) |
⬆️ |
| ... and 2 more |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact),ø = not affected,? = missing data
Powered by Codecov. Last update a60053b...244ca1e. Read the comment docs.
—
You are receiving this because you commented.
I guess that's a possibility, but I think there is less of an obvious use case for the other properties, at least I can't think of an obvious reason to check what the prompt callback for a buffer is (assuming you created the buffer). In the case of the effective prompt text:
% which gets used if the prompt is not set)This certainly seemed simpler, but of course the alternative, more complete solution also works.
—
You are receiving this because you commented.
—
You are receiving this because you commented.
How about adding a separate function: prompt_getprompt() ?
That fits nicely next to prompt_setprompt().
Sure thing. This was my initial thought. I went for getbufinfo() on the basis that it was a smaller change. Reviewing the current values for it though, I think you're (both!) right, it doesn't fit well.
This actually makes it easier to check for this feature exists( '*prompt_getprompt' ), rather than has_patch( ... ) I guess.
Completing the thought process, if in future we might add more prompt_set* attributes, at which point Yegappan's suggestion of prompt_getinfo() or equivalent might be better. Let's say we add a prompt history (I think that's in the todo list), maybe we add prompt_sethistorylen( 10 ) or something. Perhaps we'd then put that in prompt_getinfo(), but again the use-case for requesting this is much more vague, and having to calculate it for every completion request (in the case of a omnifunc) is wasteful. We can therefore add prompt_getprompt() now, and if we ever need to, add prompt_getinfo() later.
—
You are receiving this because you commented.
That's done, I think.
—
You are receiving this because you commented.
@puremourning pushed 1 commit.
—
You are receiving this because you are subscribed to this thread.
OK tests fixed, this is ready now.
—
You are receiving this because you commented.