From ca36b8861952db30ee5fee3b5fb65a744afa7b3d Mon Sep 17 00:00:00 2001 From: Mariusz Glebocki Date: Sun, 6 May 2018 15:29:46 -0400 Subject: [PATCH] Do not paint long pre-edit text outside display Summary: {F5822474} Test Plan: * Turn on IME (tested with ibus+anthy) * Type (without accepting) long text using IME Expected result: text should not be drawn outside terminal Actual result: text is drawn on terminal, margins, scrollbar Reviewers: #konsole, hindenburg Reviewed By: #konsole, hindenburg Subscribers: hindenburg, #konsole Tags: #konsole Differential Revision: https://phabricator.kde.org/D12556 --- src/TerminalDisplay.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp index 4219aa8b..6f98b8f7 100644 --- a/src/TerminalDisplay.cpp +++ b/src/TerminalDisplay.cpp @@ -3395,11 +3395,12 @@ QRect TerminalDisplay::preeditRect() const if (preeditLength == 0) { return QRect(); } + const QRect stringRect(_contentRect.left() + _fontWidth * cursorPosition().x(), + _contentRect.top() + _fontHeight * cursorPosition().y(), + _fontWidth * preeditLength, + _fontHeight); - return QRect(_contentRect.left() + _fontWidth * cursorPosition().x(), - _contentRect.top() + _fontHeight * cursorPosition().y(), - _fontWidth * preeditLength, - _fontHeight); + return stringRect.intersected(_contentRect); } void TerminalDisplay::drawInputMethodPreeditString(QPainter& painter , const QRect& rect)