Cleanup expand_unprintable and avoid calling iswprint on base ascii

This commit is contained in:
Maxime Coste 2022-12-06 17:55:20 +11:00
parent 93c50b3cd9
commit a52bb9146e

View File

@ -1329,14 +1329,15 @@ void expand_unprintable(HighlightContext context, DisplayBuffer& display_buffer,
{ {
for (auto atom_it = line.begin(); atom_it != line.end(); ++atom_it) 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()), for (auto it = get_iterator(buffer, atom_it->begin()),
end = get_iterator(buffer, atom_it->end()); it < end;) end = get_iterator(buffer, atom_it->end()); it < end;)
{ {
auto coord = it.coord(); auto coord = it.coord();
Codepoint cp = utf8::read_codepoint(it, end); Codepoint cp = utf8::read_codepoint(it, end);
if (cp != '\n' and not iswprint((wchar_t)cp)) if (cp != '\n' and (cp < ' ' or cp > '~') and not iswprint((wchar_t)cp))
{ {
if (coord != atom_it->begin()) if (coord != atom_it->begin())
atom_it = ++line.split(atom_it, coord); atom_it = ++line.split(atom_it, coord);
@ -1350,7 +1351,6 @@ void expand_unprintable(HighlightContext context, DisplayBuffer& display_buffer,
} }
} }
} }
}
} }
static void update_line_specs_ifn(const Buffer& buffer, LineAndSpecList& line_flags) static void update_line_specs_ifn(const Buffer& buffer, LineAndSpecList& line_flags)