Skip to content
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

INSERT mode autocomplete by <C-n> only completes the primary selection #949

Open
sauterp opened this issue May 20, 2021 · 3 comments · May be fixed by #950
Open

INSERT mode autocomplete by <C-n> only completes the primary selection #949

sauterp opened this issue May 20, 2021 · 3 comments · May be fixed by #950

Comments

@sauterp
Copy link

sauterp commented May 20, 2021

Version
commit: 1a958f2 (latest master at this time)
vis -v vis v0.7-29-g1a958f2 +curses +lua +acl

How to reproduce

  1. Open vis.
  2. Type any word like "hello".
  3. Create more than one selection().
  4. Type the word partially like "he".
  5. Hit while in insert mode.
  6. Hit enter when "hello" is selected.

Only the primary selection will be completed. It's not a big problem, but I would find it more convenient and consistent with other features if the autocompletion would apply to all selections, like pasting. Unlike pasting, I wouldn't have a different autocomplete suggestion for each selection. That's not feasible I think. I would implement it such that the suggestions are generated based on the primary selections cursor. What do you think?

@ninewise
Copy link
Collaborator

I've seen this as well but learned to live with it. It'd be nice to get the same (primary) completion on every selection though.

@jpaulogg
Copy link

jpaulogg commented May 20, 2021

The Vis:insert function inserts keys at all cursor positions of active window. I copied few lines from digraph.lua and it is working with multiple selections and also in replace mode.

Just replace this line with that:

	if vis.mode == vis.modes.INSERT then
		vis:insert(out)
	elseif vis.mode == vis.modes.REPLACE then
		vis:replace(out)
	end

PS: This only works when the prefixes of all selections are the same

sauterp added a commit to sauterp/vis-1 that referenced this issue May 20, 2021
Autocomplete in INSERT mode by <C-n> completes all selections based on
the suggestions generated by the input at the primary selection's cursor.
@sauterp sauterp linked a pull request May 20, 2021 that will close this issue
@sauterp
Copy link
Author

sauterp commented May 20, 2021

The Vis:insert function inserts keys at all cursor positions of active window. I copied few lines from digrpah.lua and it is working with multiple selections and also in replace mode.

Just replace this line with that:

	if vis.mode == vis.modes.INSERT then
		vis:insert(out)
	elseif vis.mode == vis.modes.REPLACE then
		vis:replace(out)
	end

PS: This only works when the prefixes of all selections are the same

Thank you for the hint, I extended on this in my PR. It will only autocomplete those selections which share the same prefix as the primary selection, the others remain unchanged.

I'm not sure if this is a good solution for everyone, but it would work for me.

erf pushed a commit to erf/vis that referenced this issue Dec 30, 2022
Autocomplete in INSERT mode by <C-n> completes all selections based on
the suggestions generated by the input at the primary selection's cursor.
erf pushed a commit to erf/vis that referenced this issue Jun 8, 2023
Autocomplete in INSERT mode by <C-n> completes all selections based on
the suggestions generated by the input at the primary selection's cursor.
erf pushed a commit to erf/vis that referenced this issue Jun 22, 2023
Autocomplete in INSERT mode by <C-n> completes all selections based on
the suggestions generated by the input at the primary selection's cursor.
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 a pull request may close this issue.

3 participants