From 287217b98715faaddab019f4e17ab54fccaaec70 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 17 Oct 2022 17:46:26 +1100 Subject: Fix splitting of display atoms accross multi-columns codepoint Honor the split request by inserting an empty atom to make sure client code can assume splitting does replace one atom with two Fixes #4753 --- src/display_buffer.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/display_buffer.cc') diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 335fb5de..c9b74d04 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -108,6 +108,10 @@ DisplayLine::iterator DisplayLine::split(iterator it, ColumnCount count) auto pos = utf8::advance(get_iterator(it->buffer(), it->begin()), get_iterator(it->buffer(), it->end()), count).coord(); + if (pos == it->begin()) // Can happen if we try to split in the middle of a multi-column codepoint + return m_atoms.insert(it, {it->buffer(), {pos, pos}, it->face}); + if (pos == it->end()) + return std::prev(m_atoms.insert(std::next(it), {it->buffer(), {pos, pos}, it->face})); return split(it, pos); } -- cgit v1.2.3