Fix an assert in compute modified ranges when merging single char ranges

Due to the way Selection::min/max worked, we were creating backward
selections, with cursor < anchor, which was triggering an assert when
trying to move cursor back one char when it was already on the first
char of the buffer.
This commit is contained in:
Maxime Coste 2017-07-14 12:42:43 +09:00
parent 26cc8b3ee0
commit 53f5b3d709
4 changed files with 8 additions and 4 deletions

View File

@ -44,11 +44,12 @@ struct Selection
return m_anchor == other.m_anchor and m_cursor == other.m_cursor; return m_anchor == other.m_anchor and m_cursor == other.m_cursor;
} }
const BufferCoord& min() const { return m_anchor < m_cursor ? m_anchor : m_cursor; } // When selections are single char, we want the anchor to be considered min, and cursor max
const BufferCoord& max() const { return m_anchor < m_cursor ? m_cursor : m_anchor; } const BufferCoord& min() const { return m_anchor <= m_cursor ? m_anchor : m_cursor; }
const BufferCoord& max() const { return m_anchor <= m_cursor ? m_cursor : m_anchor; }
BufferCoord& min() { return m_anchor < m_cursor ? m_anchor : m_cursor; } BufferCoord& min() { return m_anchor <= m_cursor ? m_anchor : m_cursor; }
BufferCoord& max() { return m_anchor < m_cursor ? m_cursor : m_anchor; } BufferCoord& max() { return m_anchor <= m_cursor ? m_cursor : m_anchor; }
private: private:
BufferCoord m_anchor; BufferCoord m_anchor;

View File

@ -0,0 +1 @@
es.<ret>!echo<ret>u

View File

@ -0,0 +1 @@
aha

View File

@ -0,0 +1 @@
aha