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 <cristian.adam@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-03-09 22:30:47 +01:00
parent ddad64e176
commit b138ab1510

View File

@@ -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)