diff options
author | Juan Linietsky <reduzio@gmail.com> | 2015-03-22 15:02:15 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2015-03-22 15:02:15 -0300 |
commit | ffa556aeea9d748589f43a2192a7747e188bbe63 (patch) | |
tree | 9f8be8a06d792d6c415de17567331ae1c8906e28 /scene/gui | |
parent | da7698073f9d38c1f546b30b44d2414a718904e5 (diff) | |
parent | 11a5949ec4f3231f5a7c054a6ebb102b705ad20f (diff) |
Merge pull request #1402 from ElectricSolstice/editor_match_fix
Fixed issue #1377 about script editor parenthesis matching.
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/text_edit.cpp | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index e0bf4587bc..b26b55f076 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -498,7 +498,29 @@ void TextEdit::_notification(int p_what) { for(int j=from;j<text[i].length();j++) { CharType cc = text[i][j]; - if (cc==c) + //ignore any brackets inside a string + if (cc== '"' | cc == '\'') { + CharType quotation = cc; + do { + j++; + if (!(j<text[i].length())) { + break; + } + cc=text[i][j]; + //skip over escaped quotation marks inside strings + if (cc=='\\') { + bool escaped = true; + while (j+1<text[i].length() && text[i][j+1]=='\\') { + escaped=!escaped; + j++; + } + if (escaped) { + j++; + continue; + } + } + } while (cc!= quotation); + } else if (cc==c) stack++; else if (cc==closec) stack--; @@ -547,7 +569,30 @@ void TextEdit::_notification(int p_what) { for(int j=from;j>=0;j--) { CharType cc = text[i][j]; - if (cc==c) + //ignore any brackets inside a string + if (cc== '"' | cc == '\'') { + CharType quotation = cc; + do { + j--; + if (!(j>=0)) { + break; + } + cc=text[i][j]; + //skip over escaped quotation marks inside strings + if (cc==quotation) { + bool escaped = false; + while (j-1>=0 && text[i][j-1]=='\\') { + escaped=!escaped; + j--; + } + if (escaped) { + j--; + cc='\\'; + continue; + } + } + } while (cc!= quotation); + } else if (cc==c) stack++; else if (cc==closec) stack--; |