1
1
mirror of https://github.com/mawww/kakoune.git synced 2024-11-27 12:16:22 +03:00

Fix handling of capture matching in region highlighter

Also extend the highlight/regions test to validate that.
Thanks to lenormf for reviewing my change and finding this bug.
This commit is contained in:
Maxime Coste 2018-10-15 21:20:00 +11:00
parent 71e27c73af
commit da13b5f814
4 changed files with 4 additions and 3 deletions

View File

@ -1660,7 +1660,7 @@ void append_matches(const Buffer& buffer, LineCount line, RegexMatchList& matche
{
auto& m = *it;
const bool with_capture = capture and m[1].matched and
m[0].second - m[0].first > std::numeric_limits<uint16_t>::max();
m[0].second - m[0].first < std::numeric_limits<uint16_t>::max();
matches.push_back({
line,
(int)(m[0].first - l.begin()),

View File

@ -1 +1 @@
"abcdefgh" hehe ${ youhou{hihi} }
"abcdefgh" hehe ${ youhou{hihi} } <a></b></a> hehe

View File

@ -2,3 +2,4 @@ add-highlighter window/regions_test regions
add-highlighter window/regions_test/code default-region fill yellow
add-highlighter window/regions_test/string region %{"} %{(?<!\\)(\\\\)*"} fill green
add-highlighter window/regions_test/shell region -recurse '\{' '\$\{' '\}' fill red
add-highlighter window/regions_test/tag region -match-capture '<(\w+)>' '</(\w+)>' fill blue

View File

@ -1,5 +1,5 @@
{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }
{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "\"" }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "abcdefgh\"" }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": " hehe " }, { "face": { "fg": "red", "bg": "default", "attributes": [] }, "contents": "${ youhou{hihi} }" }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "\u000a" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] }
{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "\"" }, { "face": { "fg": "green", "bg": "default", "attributes": [] }, "contents": "abcdefgh\"" }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": " hehe " }, { "face": { "fg": "red", "bg": "default", "attributes": [] }, "contents": "${ youhou{hihi} }" }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "<a></b></a>" }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": " hehe\u000a" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] }
{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] }
{ "jsonrpc": "2.0", "method": "info_hide", "params": [] }
{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "out 1:1 " }, { "face": { "fg": "black", "bg": "yellow", "attributes": [] }, "contents": "" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " - client0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "attributes": [] }] }