dolphin: do not re-set the diff document text if it is the same

so many little details to code..

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-14 05:09:02 +03:00
parent e7262fc7ab
commit e52432efae

View file

@ -87,12 +87,15 @@ void GitCommitDialog::setupWidgets(const QStringList &changedfiles, const QStrin
{
m_changedfiles->setText(changedfiles.join(QLatin1String("\n")));
if (m_diffdocument) {
// NOTE: can't set the text in read-only mode
m_diffdocument->setReadWrite(true);
m_diffdocument->setText(diff);
// NOTE: after KTextEditor::Document::setText() the cursor is at the end
m_diffdocument->activeView()->setCursorPosition(KTextEditor::Cursor::start());
m_diffdocument->setReadWrite(false);
// by not re-setting the text the cursor position and selection is preserved
if (m_diffdocument->text() != diff) {
// NOTE: can't set the text in read-only mode
m_diffdocument->setReadWrite(true);
m_diffdocument->setText(diff);
// NOTE: after KTextEditor::Document::setText() the cursor is at the end
m_diffdocument->activeView()->setCursorPosition(KTextEditor::Cursor::start());
m_diffdocument->setReadWrite(false);
}
} else {
m_difffiles->setText(diff);
}