diff options
| author | Chris Webb <chris@arachsys.com> | 2023-05-09 22:56:55 +0200 |
|---|---|---|
| committer | Johannes Altmanninger <aclopte@gmail.com> | 2023-05-09 23:07:07 +0200 |
| commit | fc6f32f9ee409bf755b420263eb698e8e5d6ccca (patch) | |
| tree | a117a45c4195fa249d300e0fb9198b8621a95389 /src/normal.cc | |
| parent | 2adc81c4c937e2422b1f3fa7cf470e1e7b040ffa (diff) | |
Stop _ from tearing multibyte UTF-8 sequences
Fixes #4887
[ja: add test]
Diffstat (limited to 'src/normal.cc')
| -rw-r--r-- | src/normal.cc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/normal.cc b/src/normal.cc index e3220521..2bc7fc17 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1768,6 +1768,7 @@ void spaces_to_tabs(Context& context, NormalParams params) void trim_selections(Context& context, NormalParams) { + using Utf8It = utf8::iterator<BufferIterator>; auto& buffer = context.buffer(); ScopedSelectionEdition selection_edition{context}; auto& selections = context.selections(); @@ -1776,8 +1777,8 @@ void trim_selections(Context& context, NormalParams) for (int i = 0; i < (int)selections.size(); ++i) { auto& sel = selections[i]; - auto beg = buffer.iterator_at(sel.min()); - auto end = buffer.iterator_at(sel.max()); + auto beg = Utf8It{buffer.iterator_at(sel.min()), buffer}; + auto end = Utf8It{buffer.iterator_at(sel.max()), buffer}; while (beg != end and is_blank(*beg)) ++beg; while (beg != end and is_blank(*end)) @@ -1787,8 +1788,8 @@ void trim_selections(Context& context, NormalParams) to_remove.push_back(i); else { - sel.min() = beg.coord(); - sel.max() = end.coord(); + sel.min() = beg.base().coord(); + sel.max() = end.base().coord(); } } |
