mirror of
https://github.com/mawww/kakoune.git
synced 2024-11-23 23:34:12 +03:00
Fix unintended interpretation of ranges length syntax
Ranges specified with a +<length> were inconsistent, with +0 meaning an empty range, while +1 meant a two character long range (first character + the following one). Change that to mean a single character. Fixes #3479
This commit is contained in:
parent
63371da8aa
commit
08e0b663f7
@ -58,7 +58,7 @@ define-command -params ..1 -docstring %{
|
||||
}
|
||||
|
||||
else if (/^[#&]/) {
|
||||
word_len = length($2) - 1
|
||||
word_len = length($2)
|
||||
word_pos = substr($0, 1, 1) == "&" ? substr($4, 1, length($4) - 1) : $3;
|
||||
regions = regions " " line_num "." word_pos "+" word_len "|Error"
|
||||
}
|
||||
|
@ -1481,7 +1481,7 @@ InclusiveBufferRange option_from_string(Meta::Type<InclusiveBufferRange>, String
|
||||
if (*sep == '+')
|
||||
{
|
||||
auto len = str_to_int({sep+1, str.end()});
|
||||
return {first, len == 0 ? BufferCoord{-1,-1} : BufferCoord{first.line, first.column + len}};
|
||||
return {first, len == 0 ? BufferCoord{-1,-1} : BufferCoord{first.line, first.column + len - 1}};
|
||||
}
|
||||
|
||||
const BufferCoord last{str_to_int({sep+1, dot_end}) - 1, str_to_int({dot_end+1, str.end()}) - 1};
|
||||
|
1
test/highlight/ranges/cmd
Normal file
1
test/highlight/ranges/cmd
Normal file
@ -0,0 +1 @@
|
||||
|
4
test/highlight/ranges/in
Normal file
4
test/highlight/ranges/in
Normal file
@ -0,0 +1,4 @@
|
||||
foo
|
||||
bar
|
||||
baz
|
||||
%( )
|
3
test/highlight/ranges/rc
Normal file
3
test/highlight/ranges/rc
Normal file
@ -0,0 +1,3 @@
|
||||
declare-option range-specs r
|
||||
add-highlighter window/ ranges r
|
||||
set window r %val{timestamp} 1.1+0|default,red 2.1,2.1|default,red 3.1+2|default,red
|
2
test/highlight/ranges/script
Normal file
2
test/highlight/ranges/script
Normal file
@ -0,0 +1,2 @@
|
||||
ui_out '{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }'
|
||||
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "foo\u000a" }], [{ "face": { "fg": "default", "bg": "red", "attributes": [] }, "contents": "b" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "ar\u000a" }], [{ "face": { "fg": "default", "bg": "red", "attributes": [] }, "contents": "ba" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "z\u000a" }], [{ "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": " " }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\u000a" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] }'
|
Loading…
Reference in New Issue
Block a user