summaryrefslogtreecommitdiffstats
path: root/scene/gui/code_edit.cpp
diff options
context:
space:
mode:
authorRémi Verschelde <remi@verschelde.fr>2022-01-24 21:33:14 +0100
committerGitHub <noreply@github.com>2022-01-24 21:33:14 +0100
commit33960b3b87f663923bc7d29a8cfaed77060e1056 (patch)
treed796a1cd86222a47289d50cb798ea6c752922a44 /scene/gui/code_edit.cpp
parent2255777fb9db0f51ea7f5bbb9da98d80f6a3b992 (diff)
parent6f1089af861d74f116e1163f8ead9e3a42abddaa (diff)
downloadredot-engine-33960b3b87f663923bc7d29a8cfaed77060e1056.tar.gz
Merge pull request #55884 from preslavnpetrov/ctrl-enter-deleting-selection-fix-master
Diffstat (limited to 'scene/gui/code_edit.cpp')
-rw-r--r--scene/gui/code_edit.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/gui/code_edit.cpp b/scene/gui/code_edit.cpp
index 8da7264b02..8924c37c50 100644
--- a/scene/gui/code_edit.cpp
+++ b/scene/gui/code_edit.cpp
@@ -937,8 +937,10 @@ void CodeEdit::_new_line(bool p_split_current_line, bool p_above) {
return;
}
- const int cc = get_caret_column();
+ /* When not splitting the line, we need to factor in indentation from the end of the current line. */
+ const int cc = p_split_current_line ? get_caret_column() : get_line(get_caret_line()).length();
const int cl = get_caret_line();
+
const String line = get_line(cl);
String ins = "\n";
@@ -1012,6 +1014,8 @@ void CodeEdit::_new_line(bool p_split_current_line, bool p_above) {
bool first_line = false;
if (!p_split_current_line) {
+ deselect();
+
if (p_above) {
if (cl > 0) {
set_caret_line(cl - 1, false);