1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-03 09:39:38 +02:00

Add indentation requirement for line continuation

Related commit:
- https://github.com/gorhill/uBlock/commit/703c525b01aa

This adds an indentation requirement for line
continuation to take place. The conditions are now
as follow:
- Current line ends with ` \`: ASCII space + backslash
- Next line starts with `    `: four ASCII spaces
This commit is contained in:
Raymond Hill 2020-03-15 08:15:17 -04:00
parent 703c525b01
commit ca80d2826b
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 6 additions and 0 deletions

View File

@ -121,6 +121,7 @@ CodeMirror.defineMode("ubo-static-filtering", function() {
if ( line.endsWith(' \\') ) {
do {
line = stream.lookAhead(lines.length);
if ( line.startsWith(' ') === false ) { break; }
lines.push(line);
} while ( line.endsWith(' \\') );
}

View File

@ -808,6 +808,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
if ( line.length === 0 ) { continue; }
while ( line.endsWith(' \\') ) {
if ( lineIter.peek(4) !== ' ' ) { break; }
line = line.slice(0, -2).trim() + lineIter.next().trim();
}

View File

@ -242,6 +242,10 @@
this.offset = lineEnd + 1;
return line;
}
peek(n) {
const offset = this.offset;
return this.text.slice(offset, offset + n);
}
charCodeAt(offset) {
return this.text.charCodeAt(this.offset + offset);
}