Skip to content

Conversation

@Andriamanitra
Copy link
Contributor

The fix is only relevant for certain plugins, but I think this is more correct behavior anyway.

fixes #3649

@matthias314
Copy link
Contributor

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.

@Andriamanitra
Copy link
Contributor Author

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 Autocomplete and CycleAutocomplete and change the default binding for Tab to CycleAutocomplete|Autocomplete|Indent|InsertTab. I still think that would be slightly more elegant solution – but it would mess with users' keybindings so I decided against it.

@matthias314
Copy link
Contributor

I think it's better to modify Autocomplete because this problem already arises when starting autocompletion. For example, for my LaTeX plugin, when I press TAB after \ref{, I want to start autocompletion with all labels defined in the file. If one only changed CycleAutocomplete, then that wouldn't work because of the { character.

Comment on lines +914 to 921
if b.HasSuggestions {
b.CycleAutocomplete(true)
return true
}

if h.Cursor.X == 0 {
return false
}
Copy link
Collaborator

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?

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
	}

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Collaborator

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.

@JoeKar JoeKar merged commit 79fe4ae into zyedidia:master Apr 15, 2025
6 checks passed
theredcmdcraft pushed a commit to theredcmdcraft/micro that referenced this pull request May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Autocompletions ending with non-word characters can only be cycled through with CycleAutocompleteBack

3 participants