Skip to content

Commit

Permalink
fix: Process Shift+Enter as pure Enter (Megaxela#16)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ouuan authored May 9, 2020
1 parent 869eac8 commit 69503b5
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/internal/QCodeEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)

if (!completerSkip)
{
if ((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter))
if ((e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) && e->modifiers() != Qt::NoModifier)
{
QKeyEvent pureEnter(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
if (e->modifiers() == Qt::ControlModifier)
Expand All @@ -636,6 +636,11 @@ void QCodeEditor::keyPressEvent(QKeyEvent *e)
}
return;
}
else if (e->modifiers() == Qt::ShiftModifier)
{
keyPressEvent(&pureEnter);
return;
}
}

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

0 comments on commit 69503b5

Please sign in to comment.