fix cycling through completion suggestions ending in non-word character#3650
Conversation
|
I've come across the same issue for the LaTeX plugin I'm working on, and I've come up with the same fix matthias314@f13dc1c. It works well. |
Good to know that this patch is not entirely useless to everyone besides me, and that's funny that you came up with the exact same fix! 😄 My first thought was to separate |
|
I think it's better to modify |
| if b.HasSuggestions { | ||
| b.CycleAutocomplete(true) | ||
| return true | ||
| } | ||
|
|
||
| if h.Cursor.X == 0 { | ||
| return false | ||
| } |
There was a problem hiding this comment.
Can we have more than one suggestion (b.HasSuggestions = true), when the cursor is at the first position in the line?
https://github.com/zyedidia/micro/blob/b88300ef7f0a5756520094194dd1c83b5f8130c3/internal/buffer/autocomplete.go#L72
Says no, or?
Is it possible in plugins?
Otherwise maybe merge this check with h.Cursor.HasSelection() into:
if h.Cursor.HasSelection() || h.Cursor.X == 0 {
return false
}There was a problem hiding this comment.
Is it possible in plugins?
Who knows? Giving plugin developers more freedom is better In my opinion than saving a few lines of code.
There was a problem hiding this comment.
I don't know of a use case for suggestions at the start of the line but I tend to agree with @matthias314 – rather keep the option available just in case.
There was a problem hiding this comment.
Hm...the question was more targeted into the direction if there was a special reason to move the black above if h.Cursor.X == 0 { and not below?
I don't know of a use case for suggestions at the start of the line [...]
So it was an unconscious decision? 😉
Anyway, if you both think it might be relevant in the future...then fine by me.
The fix is only relevant for certain plugins, but I think this is more correct behavior anyway.
fixes #3649