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

In visual mode, : command input moves the cursor to the end of the selected range #48

Closed
KSR-Yasuda opened this issue Jun 10, 2024 · 3 comments

Comments

@KSR-Yasuda
Copy link

With this plugin, pushing : in visual selected,
the cursor moves the end of the range.

:new
:0r !seq 1 20       " Put the line number to each line.

:setl nu rnu        " Set `releativenumber`

:10
Shift-V
4j                  " Visual select L10 - 14 (cursor is at L14).
o                   " Move the cursor to the head of the range, L10.

:                   " Begin to input command,
                    " and it moves the cursor to the end of the range, L14, unexpectedly.

vim_rnu_range_20240607_104635

With relativenumber option, this is harmful:
commands works as the cursor is at the head of the range ('<),
but displayed relativenumbers are not the relative ones from the line.

Could you take a look into this?

cf. vim-jp/issues#1432

@KSR-Yasuda
Copy link
Author

The cursor() looks moving the cursor pos to the range end '>.

--- a/autoload/traces.vim
+++ b/autoload/traces.vim
@@ -582,7 +582,6 @@ function! s:pos_range(end, pattern) abort
     endif
     unlet s:buf[s:nr].pre_cmdl_view
   endif
-  call cursor([a:end, 1])
   if !empty(a:pattern)
     call s:search(a:pattern, 'c', a:end, s:search_timeout_remaining)
   endif

Why does it need this?

@markonm
Copy link
Owner

markonm commented Jun 10, 2024

The plugin previews the range by moving the cursor to the end of the range. The cursor is moved only when Command-line mode is active. After the preview is over, the cursor is restored to its original position.

If you don't like that behavior, try adding the following to your vimrc:

let g:traces_preserve_view_state = 1

@KSR-Yasuda
Copy link
Author

@markonm Thank you, it was fixed with this option!

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

No branches or pull requests

2 participants