From d5c10472f60be4351ae52d767b085da3aa9b2942 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 18 Sep 2017 09:52:24 +0900 Subject: [PATCH] Avoid wrapping between punctuation and word Fixes #1550 --- src/highlighters.cc | 2 +- test/highlight/wrap/avoid-odd-places/cmd | 1 + test/highlight/wrap/avoid-odd-places/display | 6 ++++++ test/highlight/wrap/avoid-odd-places/in | 1 + test/highlight/wrap/avoid-odd-places/rc | 1 + 5 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/highlight/wrap/avoid-odd-places/cmd create mode 100644 test/highlight/wrap/avoid-odd-places/display create mode 100644 test/highlight/wrap/avoid-odd-places/in create mode 100644 test/highlight/wrap/avoid-odd-places/rc diff --git a/src/highlighters.cc b/src/highlighters.cc index cb4c2e1df..b1b48583a 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -835,7 +835,7 @@ struct WrapHighlighter : Highlighter { StringView line = buffer[coord.line]; utf8::iterator it{&line[col], line}; - while (it != line.end() and it != line.begin() and is_word(*it)) + while (it != line.end() and it != line.begin() and is_word(*it)) --it; if (it != line.begin() and it != &line[col] and diff --git a/test/highlight/wrap/avoid-odd-places/cmd b/test/highlight/wrap/avoid-odd-places/cmd new file mode 100644 index 000000000..8b1378917 --- /dev/null +++ b/test/highlight/wrap/avoid-odd-places/cmd @@ -0,0 +1 @@ + diff --git a/test/highlight/wrap/avoid-odd-places/display b/test/highlight/wrap/avoid-odd-places/display new file mode 100644 index 000000000..85a092d60 --- /dev/null +++ b/test/highlight/wrap/avoid-odd-places/display @@ -0,0 +1,6 @@ +{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "T" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "his is a long paragraph where we will see if the wrap highlighter tries to " }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "\"Wrap\" between the quotes and the word.\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": " - unnamed0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "attributes": [] }] } +{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 0, "column": 0 }] } +{ "jsonrpc": "2.0", "method": "refresh", "params": [true] } diff --git a/test/highlight/wrap/avoid-odd-places/in b/test/highlight/wrap/avoid-odd-places/in new file mode 100644 index 000000000..3cf44b4ba --- /dev/null +++ b/test/highlight/wrap/avoid-odd-places/in @@ -0,0 +1 @@ +This is a long paragraph where we will see if the wrap highlighter tries to "Wrap" between the quotes and the word. diff --git a/test/highlight/wrap/avoid-odd-places/rc b/test/highlight/wrap/avoid-odd-places/rc new file mode 100644 index 000000000..6f3644fff --- /dev/null +++ b/test/highlight/wrap/avoid-odd-places/rc @@ -0,0 +1 @@ +add-highlighter wrap -word