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

GoSameIds end position miscalculated for identifiers at the end of line #3605

Closed
dunric opened this issue Dec 3, 2023 · 0 comments · Fixed by #3606
Closed

GoSameIds end position miscalculated for identifiers at the end of line #3605

dunric opened this issue Dec 3, 2023 · 0 comments · Fixed by #3606

Comments

@dunric
Copy link

dunric commented Dec 3, 2023

What did you expect to happen?

GoSameIds will correctly calculate starting & ending positions for a selected identifier(token) and highligh appropriately.

What happened instead?

end position of an identifier is lesser off by 1, when identifier immediately precedes End-Of-Line character:

image

See non-highlighted t of lst identifier on 65th (64th when zero-indexed) row.

Bellow is a tracing output from sameIDsHandler function.
Notice ending position on 64th row is 12 instead of 13.

{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 33, 'line': 59}, 'start': {'character': 30, 'line': 59}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 11, 'line': 63}, 'start': {'character': 8, 'line': 63}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 12, 'line': 64}, 'start': {'character': 9, 'line': 64}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 19, 'line': 67}, 'start': {'character': 16, 'line': 67}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 12, 'line': 68}, 'start': {'character': 9, 'line': 68}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 4, 'line': 69}, 'start': {'character': 1, 'line': 69}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 21, 'line': 69}, 'start': {'character': 18, 'line': 69}}}
{'uri': 'file:///home/dunric/Projects/Go/playground/lib/algorithms.go', 'range': {'end': {'character': 23, 'line': 71}, 'start': {'character': 20, 'line': 71}}}

Vim version (first three lines from :version):

VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Nov 22 2023 21:16:40)
Použité záplaty: 1-2121
přeložil Arch Linux

Go version (go version):

go version go1.21.4 linux/amd64

gopls version

gopls version Output:
golang.org/x/tools/gopls (devel)
    golang.org/x/tools/gopls@(devel)

vim-go configuration:

vim-go configuration
g:go_auto_type_info = 1
g:go_get_update = 0
g:go_doc_balloon = 0
g:go_doc_url = 'http://localhost:6060'
g:go_updatetime = 800
g:go_diagnostics_level = 1
g:go_term_enabled = 1
g:go_fold_enable = ['block', 'varconst', 'import']
g:go_metalinter_command = 'staticcheck'
g:go_doc_keywordprg_enabled = 1
g:go_doc_popup_window = 0
g:go_auto_sameids = 1
g:go_template_file = '/home/dunric/.vim/templates/skeleton.go'
g:go_metalinter_autosave = 1
g:go_gopls_use_placeholders = v:true
g:go_jump_to_error = 1
g:go_loaded_gosnippets = 1
g:go_term_mode = 'vertical botright split'
g:go_fillstruct_mode = 'gopls'
g:go_template_test_file = '/home/dunric/.vim/templates/skeleton_test.go'
g:go_loaded_install = 1

filetype detection configuration:

filetype detection
filetype detection:ON  plugin:ON  indent:ON
bhcleek added a commit to bhcleek/vim-go that referenced this issue Dec 5, 2023
Fix same id highlighting of identifiers that are at the very end of a
line.

Fixes fatih#3605
bhcleek added a commit to bhcleek/vim-go that referenced this issue Dec 5, 2023
Fix same id highlighting of identifiers that are at the very end of a
line.

Fixes fatih#3605
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.

1 participant