summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorPreslavb <preslavb@abv.bg>2021-12-12 22:07:46 +0000
committerPreslavb <preslavb@abv.bg>2022-01-23 23:14:35 +0000
commit6f1089af861d74f116e1163f8ead9e3a42abddaa (patch)
treee52197beae879e04051ead0bccef95e5beabb2aa /scene/gui
parent81c28dd706913e66288e847772d5ea0e64e7c80c (diff)
Fix selection being deleted and indentation not being accounted for
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/code_edit.cpp6
-rw-r--r--scene/gui/text_edit.cpp1
2 files changed, 6 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);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index d6b449abd1..2539236eba 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2047,6 +2047,7 @@ void TextEdit::_new_line(bool p_split_current_line, bool p_above) {
bool first_line = false;
if (!p_split_current_line) {
+ deselect();
if (p_above) {
if (caret.line > 0) {
set_caret_line(caret.line - 1, false);