summaryrefslogtreecommitdiff
path: root/scene/gui/text_edit.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-03-11 07:32:24 +0100
committerGitHub <noreply@github.com>2020-03-11 07:32:24 +0100
commite80da4a920d7c6559ac43e6650f0984d406de08b (patch)
treed189b35217e20e99346843bd82d969939eb13c5f /scene/gui/text_edit.cpp
parent05d9d1c0e727bfb5686a331b403d891da9b58ca2 (diff)
parentab6456d1bce80d0ff6709996d4fb399adda33834 (diff)
Merge pull request #36715 from dreamsComeTrue/fix-text-edit-comment-quotes
Allow single quotes [',"] in comments in TextEdit
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r--scene/gui/text_edit.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 5e925bf37f..784a6afc7b 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1856,6 +1856,7 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
bool in_single_quote = false;
bool in_double_quote = false;
+ bool found_comment = false;
int c = 0;
while (c < line.length()) {
@@ -1865,6 +1866,9 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
if (cursor.column == c) {
break;
}
+ } else if (!in_single_quote && !in_double_quote && line[c] == '#') {
+ found_comment = true;
+ break;
} else {
if (line[c] == '\'' && !in_double_quote) {
in_single_quote = !in_single_quote;
@@ -1880,7 +1884,15 @@ void TextEdit::_consume_pair_symbol(CharType ch) {
}
}
- // Disallow inserting duplicated quotes while already in string
+ // Do not need to duplicate quotes while in comments
+ if (found_comment) {
+ insert_text_at_cursor(ch_single);
+ cursor_set_column(cursor_position_to_move);
+
+ return;
+ }
+
+ // Disallow inserting duplicated quotes while already in string
if ((in_single_quote || in_double_quote) && (ch == '"' || ch == '\'')) {
insert_text_at_cursor(ch_single);
cursor_set_column(cursor_position_to_move);