This repository has been archived by the owner on Sep 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Draft: Fix highlight with unicode #77
Draft
Kamilcuk
wants to merge
2
commits into
jackguo380:master
Choose a base branch
from
Kamilcuk:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,6 +163,24 @@ function! s:common_notify_checks(server, buffer, data) abort | |
return l:bufnr | ||
endfunction | ||
|
||
" Convert range of bytes starting from s_line character s_char | ||
" to line e_line character e_char in buffer a:buf into a range of columns. | ||
" These are equal when each displayed character takes exactly one column, | ||
" but there's also UTF-8. | ||
function! lsp_cxx_hl#bytes_to_columns(buf, s_line, s_char, e_line, e_char) | ||
if get(g:, 'lsp_cxx_hl_use_byteidx', 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to have it's default in plugin/vim-lsp-cxx-highlight.vim. You can then access it directly via Also a doc entry would be good as well. |
||
try | ||
return [byteidx(getbufline(a:buf, a:s_line)[0], a:s_char), | ||
\ byteidx(getbufline(a:buf, a:e_line)[0], a:e_char)] | ||
" If the user fastly edits the file, this can be slower then the | ||
" edits, and `getbufline` can return zero lines or these columns | ||
" may just not exists anymore. | ||
catch /^Vim\%((\a\+)\)\=:E684/ | ||
endtry | ||
endif | ||
return [ a:s_char, a:e_char ] | ||
endfunction | ||
|
||
" Section: Misc Helpers | ||
function! s:uri2bufnr(uri) abort | ||
" Absolute paths on windows has 3 leading / | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer this outside the function and each place we need to call it we wrap that. It's a bit more repeated code but we avoid the call which might have less of an impact on the runtime.