diff options
| author | nyamatongwe <devnull@localhost> | 2008-12-24 00:13:22 +0000 | 
|---|---|---|
| committer | nyamatongwe <devnull@localhost> | 2008-12-24 00:13:22 +0000 | 
| commit | 4f3d781c4b929847fbd7c6f6c145eb903e3dba65 (patch) | |
| tree | 5b5f1fb7e59652ab6c58556130779317534e5916 | |
| parent | 53debf7f31f826fa086967b530c8775a75aa610f (diff) | |
| download | scintilla-mirror-4f3d781c4b929847fbd7c6f6c145eb903e3dba65.tar.gz | |
Fix for Bug #2450963 "Continued strings fool Python lexer" from Eric
Promislow.
| -rw-r--r-- | src/LexPython.cxx | 33 | 
1 files changed, 26 insertions, 7 deletions
| diff --git a/src/LexPython.cxx b/src/LexPython.cxx index 7cc20e80a..b2c2f0558 100644 --- a/src/LexPython.cxx +++ b/src/LexPython.cxx @@ -105,12 +105,21 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  	if (startPos > 0) {  		if (lineCurrent > 0) {  			lineCurrent--; +			// Look for backslash-continued lines +			while (lineCurrent > 0) { +				int eolPos = styler.LineStart(lineCurrent) - 1; +				int eolStyle = styler.StyleAt(eolPos); +				if (eolStyle == SCE_P_STRING +				    || eolStyle == SCE_P_CHARACTER +				    || eolStyle == SCE_P_STRINGEOL) { +					lineCurrent -= 1; +				} else { +					break; +				} +			}  			startPos = styler.LineStart(lineCurrent); -			if (startPos == 0) -				initStyle = SCE_P_DEFAULT; -			else -				initStyle = styler.StyleAt(startPos - 1);  		} +		initStyle = startPos == 0 ? SCE_P_DEFAULT : styler.StyleAt(startPos - 1);  	}  	WordList &keywords = *keywordlists[0]; @@ -132,6 +141,7 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  	bool indentGood = true;  	int startIndicator = sc.currentPos; +	bool inContinuedString = false;  	for (; sc.More(); sc.Forward()) { @@ -163,8 +173,12 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  			}  			lineCurrent++;  			if ((sc.state == SCE_P_STRING) || (sc.state == SCE_P_CHARACTER)) { -				sc.ChangeState(SCE_P_STRINGEOL); -				sc.ForwardSetState(SCE_P_DEFAULT); +				if (inContinuedString) { +					inContinuedString = false; +				} else { +					sc.ChangeState(SCE_P_STRINGEOL); +					sc.ForwardSetState(SCE_P_DEFAULT); +				}  			}  			if (!sc.More())  				break; @@ -225,7 +239,12 @@ static void ColourisePyDoc(unsigned int startPos, int length, int initStyle,  				if ((sc.chNext == '\r') && (sc.GetRelative(2) == '\n')) {  					sc.Forward();  				} -				sc.Forward(); +				if (sc.chNext == '\n' || sc.chNext == '\r') { +					inContinuedString = true; +				} else { +					// Don't roll over the newline. +					sc.Forward(); +				}  			} else if ((sc.state == SCE_P_STRING) && (sc.ch == '\"')) {  				sc.ForwardSetState(SCE_P_DEFAULT);  				needEOLCheck = true; | 
