Skip to content

Commit

Permalink
Issue 735: GuiRenderLigatures emoji cursor incorrect
Browse files Browse the repository at this point in the history
QString::at does not handle multi-byte Unicode characters. A naive call will
only select the first byte from the sequence.

Use the entire UTF8 grapheme.
  • Loading branch information
jgehrig committed Dec 7, 2020
1 parent 9810052 commit 3efa484
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/gui/shellwidget/shellwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,8 +723,15 @@ void ShellWidget::paintForegroundTextBlock(
blockRect.left() + (m_cellSize.width() * cursorPos),
blockRect.top() + m_ascent + (m_lineSpace / 2) };

// Issue 735: Some characters (emoji) contain multiple bytes.
// FIXME Is QTextBoundary a better approach? Will this work for 3+ byte chars?
QString cursorText{ text.at(cursorPos) };
if (cell.IsDoubleWidth() && IsValidIndex(text, cursorPos + 1)) {
cursorText += text.at(cursorPos + 1);
}

paintNeovimCursorBackground(p, neovimCursorRect());
paintNeovimCursorForeground(p, neovimCursorRect(), cursorDrawPos, text.at(cursorPos));
paintNeovimCursorForeground(p, neovimCursorRect(), cursorDrawPos, cursorText);
}
}

Expand Down

0 comments on commit 3efa484

Please sign in to comment.