-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix cycling through completion suggestions ending in non-word character #3650
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have more than one suggestion (b.HasSuggestions = true), when the cursor is at the first position in the line?
micro/internal/buffer/autocomplete.go
Line 72 in b88300e
| if c.X == 0 || util.IsWhitespace(b.RuneAt(c.Loc.Move(-1, b))) { |
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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