Merge pull request #19187 from Zirak/editor-autocomplete-quote

Editor autocomplete won't insert unnecessary quotes
This commit is contained in:
Max Hilbrunner 2018-07-05 02:33:33 +02:00 committed by GitHub
commit e3c8ac43c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 1 deletions

View File

@ -5590,7 +5590,17 @@ void TextEdit::_confirm_completion() {
cursor_set_column(cursor.column - completion_base.length(), false);
insert_text_at_cursor(completion_current);
if (completion_current.ends_with("(") && auto_brace_completion_enabled) {
// When inserted into the middle of an existing string, don't add an unnecessary quote
String line = text[cursor.line];
CharType next_char = line[cursor.column];
CharType last_completion_char = completion_current[completion_current.length() - 1];
if ((last_completion_char == '"' || last_completion_char == '\'') &&
last_completion_char == next_char) {
_base_remove_text(cursor.line, cursor.column, cursor.line, cursor.column + 1);
}
if (last_completion_char == '(' && auto_brace_completion_enabled) {
insert_text_at_cursor(")");
cursor.column--;
}