forked from qt-creator/qt-creator
Fixed behaviour of Home and End while renaming
Also allow starting to rename with the cursor at the end of the name.
This commit is contained in:
@@ -805,7 +805,7 @@ void CPPEditor::renameInPlace()
|
|||||||
for (int i = 0; i < m_renameSelections.size(); ++i) {
|
for (int i = 0; i < m_renameSelections.size(); ++i) {
|
||||||
QTextEdit::ExtraSelection s = m_renameSelections.at(i);
|
QTextEdit::ExtraSelection s = m_renameSelections.at(i);
|
||||||
if (c.position() >= s.cursor.anchor()
|
if (c.position() >= s.cursor.anchor()
|
||||||
&& c.position() < s.cursor.position()) {
|
&& c.position() <= s.cursor.position()) {
|
||||||
m_currentRenameSelection = i;
|
m_currentRenameSelection = i;
|
||||||
m_renameSelections[i].format.setBackground(QColor(255, 200, 200));
|
m_renameSelections[i].format.setBackground(QColor(255, 200, 200));
|
||||||
setExtraSelections(CodeSemanticsSelection, m_renameSelections);
|
setExtraSelections(CodeSemanticsSelection, m_renameSelections);
|
||||||
@@ -1471,17 +1471,25 @@ void CPPEditor::keyPressEvent(QKeyEvent *e)
|
|||||||
return;
|
return;
|
||||||
case Qt::Key_Home: {
|
case Qt::Key_Home: {
|
||||||
QTextCursor c = textCursor();
|
QTextCursor c = textCursor();
|
||||||
c.setPosition(currentRenameSelection.cursor.anchor(), moveMode);
|
if (c.position() > currentRenameSelection.cursor.anchor()
|
||||||
setTextCursor(c);
|
&& c.position() <= currentRenameSelection.cursor.position()) {
|
||||||
e->accept();
|
c.setPosition(currentRenameSelection.cursor.anchor(), moveMode);
|
||||||
return;
|
setTextCursor(c);
|
||||||
|
e->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case Qt::Key_End: {
|
case Qt::Key_End: {
|
||||||
QTextCursor c = textCursor();
|
QTextCursor c = textCursor();
|
||||||
c.setPosition(currentRenameSelection.cursor.position(), moveMode);
|
if (c.position() >= currentRenameSelection.cursor.anchor()
|
||||||
setTextCursor(c);
|
&& c.position() < currentRenameSelection.cursor.position()) {
|
||||||
e->accept();
|
c.setPosition(currentRenameSelection.cursor.position(), moveMode);
|
||||||
return;
|
setTextCursor(c);
|
||||||
|
e->accept();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
case Qt::Key_Backspace: {
|
case Qt::Key_Backspace: {
|
||||||
QTextCursor c = textCursor();
|
QTextCursor c = textCursor();
|
||||||
|
|||||||
Reference in New Issue
Block a user