mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-07 03:12:33 +01: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:
parent
703c525b01
commit
ca80d2826b
@ -121,6 +121,7 @@ CodeMirror.defineMode("ubo-static-filtering", function() {
|
|||||||
if ( line.endsWith(' \\') ) {
|
if ( line.endsWith(' \\') ) {
|
||||||
do {
|
do {
|
||||||
line = stream.lookAhead(lines.length);
|
line = stream.lookAhead(lines.length);
|
||||||
|
if ( line.startsWith(' ') === false ) { break; }
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
} while ( line.endsWith(' \\') );
|
} while ( line.endsWith(' \\') );
|
||||||
}
|
}
|
||||||
|
@ -808,6 +808,7 @@ self.addEventListener('hiddenSettingsChanged', ( ) => {
|
|||||||
if ( line.length === 0 ) { continue; }
|
if ( line.length === 0 ) { continue; }
|
||||||
|
|
||||||
while ( line.endsWith(' \\') ) {
|
while ( line.endsWith(' \\') ) {
|
||||||
|
if ( lineIter.peek(4) !== ' ' ) { break; }
|
||||||
line = line.slice(0, -2).trim() + lineIter.next().trim();
|
line = line.slice(0, -2).trim() + lineIter.next().trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +242,10 @@
|
|||||||
this.offset = lineEnd + 1;
|
this.offset = lineEnd + 1;
|
||||||
return line;
|
return line;
|
||||||
}
|
}
|
||||||
|
peek(n) {
|
||||||
|
const offset = this.offset;
|
||||||
|
return this.text.slice(offset, offset + n);
|
||||||
|
}
|
||||||
charCodeAt(offset) {
|
charCodeAt(offset) {
|
||||||
return this.text.charCodeAt(this.offset + offset);
|
return this.text.charCodeAt(this.offset + offset);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user