From 11a5949ec4f3231f5a7c054a6ebb102b705ad20f Mon Sep 17 00:00:00 2001 From: ElectricSolstice Date: Thu, 19 Feb 2015 16:34:04 -0800 Subject: [PATCH] Fixed issue 1377 about script editor parenthesis matching. --- scene/gui/text_edit.cpp | 49 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8855627bb4b..a0d5af2efcc 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=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--;