Skip to content

Add multicursor autocompletions - #4028

Merged
JoeKar merged 1 commit into
micro-editor:masterfrom
redsti-github:feature/multicursor-autocomplete
Aug 24, 2026
Merged

Add multicursor autocompletions#4028
JoeKar merged 1 commit into
micro-editor:masterfrom
redsti-github:feature/multicursor-autocomplete

Conversation

@redsti-github

@redsti-github redsti-github commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Implements autocomplete while using multiple cursors. (loosely based on #3442)

Only autocompletes cursors which end in the same word as the active cursor.

For example:

foo bar
f|     -> foo|
f|     -> foo|
b|     -> b|
f|b    -> f|b

Closes #3442

@JoeKar

JoeKar commented Mar 1, 2026

Copy link
Copy Markdown
Member

But we already have #3442 and this use case is discussed within it?!
I don't see any reason to duplicate the PR.

@redsti-github

Copy link
Copy Markdown
Contributor Author

Yes, but #3442 still autocompletes on all cursors, even if they shouldn't be.
I created this PR because as far as i know, i can't add or suggest commits to someone else's PR. (Atleast not without opening a PR to the author's repo, or commenting a diff, both of which feel impractical to me.)

Comment thread internal/buffer/autocomplete.go Outdated
@Neko-Box-Coder

Copy link
Copy Markdown
Contributor

Tested the changes, works well as expected. Nice one.

Comment thread internal/buffer/autocomplete.go Outdated
@Neko-Box-Coder

Neko-Box-Coder commented Mar 21, 2026

Copy link
Copy Markdown
Contributor

Hey @redsti-github , I want to merge this to my own fork.

Could you tidy up the commits please?
i.e. "fix plugin support" and "remove trailing whitespace" should be in "Autocomplete support for multiple cursors" instead of having their own commits.

Thanks.

@redsti-github
redsti-github force-pushed the feature/multicursor-autocomplete branch from 325e85c to 5c71c2e Compare March 24, 2026 11:35
@Neko-Box-Coder

Copy link
Copy Markdown
Contributor

I have tested this on my own fork for quite awhile and I haven't encountered any issues. Maybe we can merge this @JoeKar @dmaluka ?

Comment thread internal/buffer/autocomplete.go Outdated
Comment thread internal/buffer/autocomplete.go Outdated
Comment thread internal/buffer/autocomplete.go Outdated
Comment thread internal/buffer/autocomplete.go Outdated
@redsti-github
redsti-github force-pushed the feature/multicursor-autocomplete branch from 5c71c2e to 5b66d78 Compare August 22, 2026 10:26
Comment thread internal/buffer/autocomplete.go Outdated
Comment thread internal/buffer/autocomplete.go Outdated
@redsti-github
redsti-github force-pushed the feature/multicursor-autocomplete branch from 5b66d78 to 54c5bc5 Compare August 23, 2026 19:14
@JoeKar
JoeKar merged commit 4c47a27 into micro-editor:master Aug 24, 2026
6 checks passed
@dmaluka

dmaluka commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

This caused a serious regression: autocompletion in the command bar doesn't work unless the cursor is after a word.

For example, open the command prompt and press Tab - nothing happens (while it should suggest commands to execute).

Or for example, open the command prompt, type open and press Tab - nothing happens (while it should suggest files to open).

@Neko-Box-Coder

Neko-Box-Coder commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

So there are 2 autocomplete functions (confusingly), one in buffer and one in action, where the action one calls the buffer one.

And there's also CommandComplete, for the command bar, which calls the buffer autocomplete directly.

Previously, the autocomplete in the action one was guarded with some autocomplete logic (is the cursor in words, etc...).

This PR moved the guard to the buffer autocomplete, and now the CommandComplete which wasn't guarded by this logic before is guarded now. Unfortunately I didn't spot this :/ (I have always typed the first few letters before auto-completing...)

I guess the fix would be moving the guard back to the action autocomplete function instead of in the buffer one?

@Andriamanitra

Copy link
Copy Markdown
Collaborator

I also noticed this quirk that can happen when the words under different cursors don't match:

https://asciinema.org/a/mc6ZvLipLNBv1Wmd

This also broke plugins that autocomplete sequences with non-word characters. For example jlabbrev lets you autocomplete \^ to various LaTeX superscript expressions (\^2, \^alpha, \^(, ...). I confirmed that #4200 fixes that issue for single cursor but it won't work with multiple cursors (we can probably declare this out-of-scope but it's worth mentioning):

https://asciinema.org/a/HNbCisuhK554vUKP

Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request Aug 27, 2026
Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request Aug 27, 2026
Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request Aug 28, 2026
Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request Aug 30, 2026
Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request Aug 30, 2026
PR micro-editor#4028 moved the check for autocomplete from action autocomplete to the buffer one, which caused a few regression for upstream callers that use the buffer autocomplete.

This commit restores pre micro-editor#4028 behavior by adding a callback variant for buffer autocomplete functions while keeping the multi-cursor autocomplete function.
Neko-Box-Coder added a commit to Neko-Box-Coder/micro-dev that referenced this pull request Aug 30, 2026
PR micro-editor#4028 moved the check for autocomplete from action autocomplete to
the buffer one, which caused a few regression for upstream callers
(commandbar autocomplete & plugins that use buffer autocomplete)
that use the buffer autocomplete.

This commit restores pre micro-editor#4028 behavior by adding a callback variant
for buffer autocomplete functions while keeping the multi-cursor
autocomplete function.
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.

5 participants