Skip to content

Commit

Permalink
fix breaking unicode presentation when cursor in column mode is set in
Browse files Browse the repository at this point in the history
the middle of a multi-char character

related to #2427
  • Loading branch information
sunderme committed Jul 3, 2022
1 parent 90d9be4 commit ae98f3f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/qcodeedit/lib/document/qdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4606,7 +4606,12 @@ void QDocumentCursorHandle::setColumnNumber(int c, int m)
if ( !m_doc )
return;

QDocumentLine /*l1 = m_doc->line(m_begLine), */l2 = m_doc->line(m_endLine);
QDocumentLine l1 = m_doc->line(m_begLine), l2 = m_doc->line(m_endLine);

// make sure column is not in the middle of a composite character (two utf-16 characters low/hi surrogate, see QString)
if(l1.length()>c && l1.text().at(c).isLowSurrogate()){
++c;
}

if ( m & QDocumentCursor::KeepAnchor )
{
Expand Down

0 comments on commit ae98f3f

Please sign in to comment.