Skip to content

Commit 69503b5

Browse files
authored
fix: Process Shift+Enter as pure Enter (Megaxela#16)
Before this commit, Shift+Enter adds a new line in the same block, and result in a wrong line number. It is somehow fine if only the line number is wrong, but with the language server, the squiggles are also in the wrong place, thus it's necessary to fix this.
1 parent 869eac8 commit 69503b5

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/internal/QCodeEditor.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)
610610

611611
if (!completerSkip)
612612
{
613-
if ((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter))
613+
if ((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && e->modifiers() != Qt::NoModifier)
614614
{
615615
QKeyEvent pureEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
616616
if (e->modifiers() == Qt::ControlModifier)
@@ -636,6 +636,11 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)
636636
}
637637
return;
638638
}
639+
else if (e->modifiers() == Qt::ShiftModifier)
640+
{
641+
keyPressEvent(&pureEnter);
642+
return;
643+
}
639644
}
640645

641646
if (e->key() == Qt::Key_Tab && e->modifiers() == Qt::NoModifier)

0 commit comments

Comments
 (0)