-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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
:goto is broken with text properties #5930
Comments
Workaround: since things work at line boundaries, line2byte and byte2line both seem to work. For a quick hack
(This only gives the right answer with a recent vim, with my distro 8.1.2269 byte2line is broken too) |
Summary: Do line/col to byte conversions on the python side rather than relying on vim. Its calculations are off when text annotations are present: - vim/vim#5930 - vim/vim#3718 (fixed, but vim 8.1 is still common) Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78198
This bug (and a related predecessor) cause `:goto` and `line2bytes()` to do the wrong thing when vim textprops are used. This manifests as "cursor jumps around randomly after formatting" when using plugins that use textprops for diagnostics, highlighting etc. We happen to have all the code in an array when we need to do cursor coordinate conversions, so we do those in vimscript instead of querying vim. Without this patch, The newly added test fails on affected versions of vim including both vim master and debian's 8.1.2269 (in different ways). Vim bug tracker entry: vim/vim#5930 Similar workaround in first-party vim integration: llvm/llvm-project@591be7e
clang-format: work around vim/vim#5930 when positioning cursor
Summary: Do line/col to byte conversions on the python side rather than relying on vim. Its calculations are off when text annotations are present: - vim/vim#5930 - vim/vim#3718 (fixed, but vim 8.1 is still common) Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78198
Has the bug in vim been fixed? |
@dbarnett wrote:
The bug has simple reproducible steps.
|
Ran into the same bug and did some debugging before finding this issue. To add something very minor to the conversation, here's a regression test that can be added to func Test_prop_go()
enew
call setline(0, 'one')
call setline(1, '')
call setline(2, 'two')
call setline(3, '')
call setline(4, 'three four')
call prop_type_add('testprop', {'highlight': 'Directory'})
call search('^two')
call prop_add(line('.'), col('.'), {
\ 'length': len('two'),
\ 'type': 'testprop'
\ })
call search('three \zsfour')
let expected_byte_position = line2byte(line('.')) + col('.') - 1
exe expected_byte_position 'goto'
let actual_byte_position = line2byte(line('.')) + col('.') - 1
eval actual_byte_position->assert_equal(expected_byte_position)
call prop_type_delete('testprop')
bwipe!
endfunc If the |
Summary: Do line/col to byte conversions on the python side rather than relying on vim. Its calculations are off when text annotations are present: - vim/vim#5930 - vim/vim#3718 (fixed, but vim 8.1 is still common) Reviewers: hokein Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78198
Describe the bug
When
textprop
s are set,:goto
goes to the wrong position in some cases. The ifdef'd calculations inml_find_line_or_offset
seem to be incorrect.To Reproduce
:call prop_type_add('foo', {})
:call prop_add(1,1,{'length':2, 'type':'foo'})
:goto 4
goes to line 1 col 3 (correct):goto 5
goes to line 2 col 1 (correct):goto 6
goes to line 2 col 1 (incorrect):goto
from 7 - 15 also goes to line 2 col 1 (incorrect):goto 16
goes to line 3 col 1 (correct)Expected behavior
:goto 6
should go to line 2 col 2:goto 7
should go to line 2 col 3 etcEnvironment (please complete the following information):
Additional context
The relevant call to
ml_find_line_or_offset
stores a negative offset in*offp
which seems suspicios (e.g.:goto 5
-> -20,:goto 6
-> -19).But I don't understand the code well enough to proceed further myself.
My distro-installed vim is 8.1.2269 and shows quite different incorrect behavior for the same
:goto
s, jumping to the start or end of buffer. My guess is b413d2e was intended to fix this but was not correct.The text was updated successfully, but these errors were encountered: