mirror of https://github.com/gorhill/uBlock.git
Fix last newline not being automatically appended
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/657
This commit is contained in:
parent
9d1913a16e
commit
47a5caef54
|
@ -152,8 +152,10 @@ const rulesToDoc = function(clearHistory) {
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/593
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/593
|
||||||
// Ensure the text content always ends with an empty line to avoid
|
// Ensure the text content always ends with an empty line to avoid
|
||||||
// spurious diff entries.
|
// spurious diff entries.
|
||||||
let beforeText = doc.getValue().trim();
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/657
|
||||||
if ( beforeText !== '' ) { beforeText += '\n'; }
|
// Diff against unmodified beforeText so that the last newline can
|
||||||
|
// be reported in the diff and thus appended if needed.
|
||||||
|
let beforeText = doc.getValue();
|
||||||
let afterText = rules.join('\n').trim();
|
let afterText = rules.join('\n').trim();
|
||||||
if ( afterText !== '' ) { afterText += '\n'; }
|
if ( afterText !== '' ) { afterText += '\n'; }
|
||||||
const diffs = differ.diff_main(beforeText, afterText);
|
const diffs = differ.diff_main(beforeText, afterText);
|
||||||
|
|
Loading…
Reference in New Issue