diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-12-06 17:55:20 +1100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-12-06 17:55:20 +1100 |
| commit | a52bb9146e5673ceaf6081833cf7183fc3f7ff9d (patch) | |
| tree | b6f844883e91c56a13bae62c9114c240bec13829 /src | |
| parent | 93c50b3cd97ef78c678aa84010a5481ce0f11245 (diff) | |
Cleanup expand_unprintable and avoid calling iswprint on base ascii
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc index ed3426e8..8f7a97f3 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -1329,24 +1329,24 @@ void expand_unprintable(HighlightContext context, DisplayBuffer& display_buffer, { for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it) { - if (atom_it->type() == DisplayAtom::Range) + if (atom_it->type() != DisplayAtom::Range) + continue; + + for (auto it = get_iterator(buffer, atom_it->begin()), + end = get_iterator(buffer, atom_it->end()); it < end;) { - for (auto it = get_iterator(buffer, atom_it->begin()), - end = get_iterator(buffer, atom_it->end()); it < end;) + auto coord = it.coord(); + Codepoint cp = utf8::read_codepoint(it, end); + if (cp != '\n' and (cp < ' ' or cp > '~') and not iswprint((wchar_t)cp)) { - auto coord = it.coord(); - Codepoint cp = utf8::read_codepoint(it, end); - if (cp != '\n' and not iswprint((wchar_t)cp)) - { - if (coord != atom_it->begin()) - atom_it = ++line.split(atom_it, coord); - if (it.coord() < atom_it->end()) - atom_it = line.split(atom_it, it.coord()); + if (coord != atom_it->begin()) + atom_it = ++line.split(atom_it, coord); + if (it.coord() < atom_it->end()) + atom_it = line.split(atom_it, it.coord()); - atom_it->replace("�"); - atom_it->face = error; - break; - } + atom_it->replace("�"); + atom_it->face = error; + break; } } } |
