diff --git a/edit/beautify.js b/edit/beautify.js index e264acbe..bd86f416 100644 --- a/edit/beautify.js +++ b/edit/beautify.js @@ -82,6 +82,7 @@ function createBeautifyUI(scope, options) { $createOption('}', 'newline_between_rules'), $createLabeledCheckbox('preserve_newlines', 'styleBeautifyPreserveNewlines'), $createLabeledCheckbox('indent_conditional', 'styleBeautifyIndentConditional'), + editor.isUsercss && $createLabeledCheckbox('indent_mozdoc', '', '... @-moz-document'), ]), $create('p.beautify-hint', [ $create('span', t('styleBeautifyHint') + '\u00A0'), @@ -148,7 +149,7 @@ function createBeautifyUI(scope, options) { ); } - function $createLabeledCheckbox(optionName, i18nKey) { + function $createLabeledCheckbox(optionName, i18nKey, text) { return ( $create('label', {style: 'display: block; clear: both;'}, [ $create('input', { @@ -158,7 +159,7 @@ function createBeautifyUI(scope, options) { }), $create('SVG:svg.svg-icon.checked', $create('SVG:use', {'xlink:href': '#svg-icon-checked'})), - t(i18nKey), + i18nKey ? t(i18nKey) : text, ]) ); } diff --git a/js/prefs.js b/js/prefs.js index 454bdb10..276292d3 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -84,6 +84,7 @@ preserve_newlines: true, end_with_newline: false, indent_conditional: true, + indent_mozdoc: true, }, 'editor.beautify.hotkey': '', 'editor.lintDelay': 300, // lint gutter marker update delay, ms diff --git a/vendor-overwrites/beautify/beautify-css-mod.js b/vendor-overwrites/beautify/beautify-css-mod.js index 1c39ea84..9282350f 100644 --- a/vendor-overwrites/beautify/beautify-css-mod.js +++ b/vendor-overwrites/beautify/beautify-css-mod.js @@ -87,6 +87,7 @@ var lineBreak = /\r\n|[\n\r\u2028\u2029]/; var allLineBreaks = new RegExp(lineBreak.source, 'g'); + var MOZ_DOC = "@-moz-document"; function css_beautify(source_text, options) { options = options || {}; @@ -108,6 +109,7 @@ newline_between_rules = true, space_around_combinator = true, indent_conditional = true, + indent_mozdoc = true, newline_between_properties = true, newline_before_open_brace = false, newline_after_open_brace = true, @@ -303,7 +305,7 @@ newline_before_open_brace ? print.newLine() : print.singleSpace(); output.push(ch); outputPosCol++; - if (!enteringConditionalGroup || indent_conditional) { + if (!enteringConditionalGroup || (variableOrRule === MOZ_DOC ? indent_mozdoc : indent_conditional)) { indent(); } if (!eatWhitespace(true)) { @@ -439,7 +441,7 @@ nestedLevel += 1; if (variableOrRule in css_beautify.CONDITIONAL_GROUP_RULE) { enteringConditionalGroup = true; - if (!indent_conditional) { + if (variableOrRule === MOZ_DOC ? !indent_mozdoc : !indent_conditional) { nestedLevel--; } } @@ -628,12 +630,12 @@ // also in CONDITIONAL_GROUP_RULE below "@media": true, "@supports": true, - "@-moz-document": true + [MOZ_DOC]: true }; css_beautify.CONDITIONAL_GROUP_RULE = { "@media": true, "@supports": true, - "@-moz-document": true + [MOZ_DOC]: true }; /*global define */