Closed JS-Zheng closed 2 years ago
Hi Jason, Thank you for finding this error and opening the issue. I think now the new version 1.39.9 will solve this problem.
Hi Azabiong, thanks for creating such a useful plug in! It helps me fight many annoying logs. But this issue still exists, the highlight of the single-character cannot work properly.
I think this issue is caused by the following statement in s:GetVisualLine()
function:
if l:left == l:right | return '' | endif
Therefore, I open a pull request #8, for your reference only, to try to solve this issue and this approach can introduce new multi-line highlight feature, by the way.
IMHO, both features (i.e., multi-line, single-char highlight) are very useful. However, some existing features (e.g., HiFind
, HiErase
) may be affected and still need further verification.
Hi Jason, Thank you very much for your update! It's looks very good! 👍 Could you please upload this text block or send it to me so I can check it?
And yes, as you noted, support for multiline highlighting is not ready yet. However it's in the future upgrade list.
My pleasure 😀 That Apache log is adapt from elastic/example project.
Thank you, I downloaded it. Now, how should I reproduce it or which char should I select?
Reproduce:
v
(select single character)f<CR>
(HiSet mapping)You can choose any single character and not limited to the question mark (i.e., ?
).
IMHO, you don't need to download that example log, and you can open any text file for testing :)
Thank you, I'm using 1.39.9, but I couldn't reproduce 1.39.8 symptom... 😅 What should I do...
Could you highlight a single character in 1.39.9?
In my test (following above reproduce steps):
s:GetVisualLine()
returns a empty string)\V
)Yes, I can highlight single characters in 1.39.9 using v
and moving cursor to right l
and f enter
.
It seems that v1.39.8 \V
was the root cause. If so, I think 1.39.9 will fix that. What do you think?
What's your 'selection'
(i.e., 'sel'
) setting in Vim?
My sel
value is 'inclusive', so I don't need to moving cursor left/right after using v
.
I guess it may be the problem in s:GetVisualLine()
:
...
if l:left == l:right | return '' | endif <----- **this line doesn't consider &selection**
if l:right > 0
let l:right -= &selection == 'inclusive' ? 1 : 2
endif
...
Wow, you find the issue very quickly! 👍
My selection
setting is exclusive
, and it shows the difference, as you mentioned!
My pleasure 😀, very glad to improve this awesome project!
I think now v1.40 will resolve the issue. It seems to select unicode characters correctly too 😁
I added your name to Credits section h: Hi-Credits
It works well! Thanks! 😆
Hi Jason, now Jump to Highlights feature is supported, and I think it can be useful when you analyze logs 😄
Wow! Great feature and efficient development You're so thoughtful, thanks 😆
Hi @azabiong, some advices
matchadd()
doesn't uses 'magic', 'smartcase' and 'ignorecase' options, however, search()
uses them.
This difference may result in the Jump to Highlights feature jump to a wrong word (e.g., when 'ignorecase' on), which is not highlighted.
Oh! thanks for the good points! 👍 I'll test and update it right away.
IMHO, you can disable ignorecase
temporarily, for example:
" save ignorecase value
try
" disable ignorecase
" do something
catch
" do something
finally
" restore ignorecase
endtry
Hope it helps 😉
Thank you so much! 😄
Alternatively, it seems straightforward to pass the case-sensitive option '\C' with the pattern to the search() function, like search('\C' . pattern)
. Now v1.50.2 supports this, thank you! 😄
It's a better and concise solution, good job! 😆
vim-highlighter version: 0e19263 vim version: 8.2.4700
When entering to the visual mode and selecting a single character,
:HiSet
will generate empty pattern (i.e.,\V
) , causing Vim highlights all characters.