From b138ab151012afc2fbbb747ff2a13f0caaf2ca8f Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 9 Mar 2023 22:30:47 +0100 Subject: [PATCH] Terminal: Fix copyToClipboard when selecting all When selecting the whole screen (e.g. while running nano) the iterator position would be "end", but the iterator state was not, as "CellIterator(this, pos)" did not check for that. Change-Id: Ie26ce27c0078f7b3fcc3c77673ac66bc273c842d Reviewed-by: Cristian Adam --- src/plugins/terminal/celliterator.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/plugins/terminal/celliterator.cpp b/src/plugins/terminal/celliterator.cpp index 76adbd5b4a3..101f7295213 100644 --- a/src/plugins/terminal/celliterator.cpp +++ b/src/plugins/terminal/celliterator.cpp @@ -22,8 +22,13 @@ CellIterator::CellIterator(const TerminalSurface *surface, int pos) : m_state(State::INSIDE) , m_surface(surface) { - m_pos = pos; m_maxpos = surface->fullSize().width() * (surface->fullSize().height()) - 1; + m_pos = qMin(m_maxpos + 1, pos); + if (m_pos == 0) { + m_state = State::BEGIN; + } else if (m_pos == m_maxpos + 1) { + m_state = State::END; + } updateChar(); } @@ -47,8 +52,6 @@ void CellIterator::updateChar() { QPoint cell = m_surface->posToGrid(m_pos); m_char = m_surface->fetchCharAt(cell.x(), cell.y()); - if (m_char == 0) - m_char = U' '; } CellIterator &CellIterator::operator-=(int n)