File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -2381,6 +2381,7 @@ void CodeEdit::confirm_code_completion(bool p_replace) {
23812381 }
23822382
23832383 // Handle merging of symbols eg strings, brackets.
2384+ caret_line = get_caret_line (i);
23842385 const String line = get_line (caret_line);
23852386 char32_t next_char = line[get_caret_column (i)];
23862387 char32_t last_completion_char = insert_text[insert_text.length () - 1 ];
@@ -3024,17 +3025,18 @@ void CodeEdit::_bind_methods() {
30243025/* Auto brace completion */
30253026int CodeEdit::_get_auto_brace_pair_open_at_pos (int p_line, int p_col) {
30263027 const String &line = get_line (p_line);
3028+ int caret_col = MIN (p_col, line.length ());
30273029
30283030 /* Should be fast enough, expecting low amount of pairs... */
30293031 for (int i = 0 ; i < auto_brace_completion_pairs.size (); i++) {
30303032 const String &open_key = auto_brace_completion_pairs[i].open_key ;
3031- if (p_col - open_key.length () < 0 ) {
3033+ if (caret_col < open_key.length ()) {
30323034 continue ;
30333035 }
30343036
30353037 bool is_match = true ;
30363038 for (int j = 0 ; j < open_key.length (); j++) {
3037- if (line[(p_col - 1 ) - j] != open_key[(open_key.length () - 1 ) - j]) {
3039+ if (line[(caret_col - 1 ) - j] != open_key[(open_key.length () - 1 ) - j]) {
30383040 is_match = false ;
30393041 break ;
30403042 }
You can’t perform that action at this time.
0 commit comments