From 4bb1a191cc50ec623fa4e23c6a3cc1e0e6526f60 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 22 Feb 2018 12:59:56 +0300 Subject: [PATCH] replace the last @-moz-document if present in a usercss template when creating a new style for the site via popup see #352 --- edit/source-editor.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/edit/source-editor.js b/edit/source-editor.js index 1e53283a..6db47d40 100644 --- a/edit/source-editor.js +++ b/edit/source-editor.js @@ -123,7 +123,8 @@ function createSourceEditor(style) { chromeSync.getLZValue('usercssTemplate').then(code => { code = code || DEFAULT_CODE; - style.sourceCode = code.replace(/\s+$/, '\n\n') + section; + // strip the last dummy section if any, add an empty line followed by the section + style.sourceCode = code.replace(/@-moz-document[^{]*\{[^}]*\}\s*$|\s+$/g, '\n\n') + section; cm.startOperation(); cm.setValue(style.sourceCode); cm.clearHistory();