-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Adding auto complete support for multi cursors #3442
base: master
Are you sure you want to change the base?
Adding auto complete support for multi cursors #3442
Conversation
@dmaluka Although slightly different but VSCode is doing something similar to what I am doing. The way it handles texts that are not the same is it will fill in the whole auto-complete word instead of partial word for places that don't have the same text. So like
Instead what this PR do atm:
But I think very few people would expect (and use) auto-complete to work properly in such situation anyway and the complexity is not worth it. |
So in those scenarios when they don't, we should at least not autocomplete the text at the given cursor at all, rather than autocomplete it with something unexpected and meaningless. I imagine it should not be difficult to add corresponding checks, for example by iterating the cursors not in But I'm still not sure what's wrong with autocompleting different words at different cursors. That would allow making |
Okay sure, I will give a go.
At first, I tried just putting AutoComplete into multi actions, and obviously it didn't work at all since it was fixated on the last cursor. But even with a bit of tweaking, what happened is that it will cycle the autocomplete field as many times as the multi cursors, which makes sense considering the function is being called for each cursor. This raises the question of how does the user know which autocomplete is being filled for each multi-cursor if each of them can fill in a different word. Not to mention there would be no way to choose which autocomplete entry for each cursor. |
Ah yeah indeed, good point, the autocomplete menu would be different for different cursors, so it is not an option. |
What checks should I be adding? |
Extracting autocomplete functions, Adding autocomplete checks to each cursor
For me personally, the most intuitive behavior would be to only allow completions which are the same across all cursors. Anything else I think of has very limited usability. Here's an edge(?) case to illustrate why I think other approaches don't work:
I could think of a number of different valid completions for 'T': So, IMO, it would be enough to filter the list of completions to ones that apply to all cursors and then cycle through that. |
Currently, auto-complete only works on the latest cursor, which makes multi-cursor editing not pleasant.
This small change should cover most of the scenarios for auto-complete on multi-cursors.