Closed tmilloff closed 7 years ago
Cursor position is always restored after highlighting. See here. Try to comment out that line and let me now if that's the behavior you want.
The cursor position is restored after pressing Enter to complete the command, but not immediately after the highlighted range is created. Commenting out that line merely prevents the cursor position from ever being restored.
Please provide steps to reproduce. I don't use numbers at all so I'm having hard time grasping the issue.
What delimiter are you using when the issue happens? I you use ;
cursor will be moved but if you use ,
it will not be moved.
Take a look at: h :;
Sorry for such a late reply. Here are a couple recordings that show the issue.
This recording shows the behavior without the plugin.
This other recording shows the behavior with the plugin. Note that after entering the range and move command, the relative line numbers change. However, when I hit enter, the command still works the same as it does without the plugin. This means that I need to remember which line to move to before I finish typing the range and command.
I uderstand now. You can achieve that behavior with the following:
diff --git a/plugin/traces.vim b/plugin/traces.vim
index 77e23b1..1c25aa5 100644
--- a/plugin/traces.vim
+++ b/plugin/traces.vim
@@ -523,6 +523,7 @@ function! s:highlight(pattern_regex, selection_regex, last_specifier_pattern, ab
silent! call s:set_cursor_position(a:pattern_regex, a:selection_regex, a:abs_range)
endif
+ call cursor(s:cursor_initial_pos)
redraw
endfunction
I could add an option, but that approach has a flaw. Patterns and ranges which are not present on starting screen will not be highlighted. Perhaps, it's better to utilize newly introduced autocommands, CmdlineEnter
and CmdlineLeave
, to turn off relative numbers when inside command-line?
Thanks so much for your quick response! I confirm that does indeed fix the problem. Could you add it as an option, turned off by default? I like that behavior despite not highlighting patterns and ranges on the starting screen, and perhaps others will as well.
When a range is highlighted, the cursor moves to the last line of the range until the command is executed. When using relative numbering this makes it hard to use commands like :t and :m, since the displayed relative numbers will change, but vim will still expect the relative numbers as displayed before the highlighting moves the cursor.
Is it possible to make a fix to keep the cursor position on the same line during the highlight, or alternatively create a setting to disable range highlighting for certain commands?