Skip to content

Commit

Permalink
Fix: Extension ruins ASCII art definitions for grid-template-areas, F…
Browse files Browse the repository at this point in the history
  • Loading branch information
ronilaukkarinen committed Oct 20, 2021
1 parent 4561632 commit 98f5b71
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v6.2.2

* Fix: Extension ruins ASCII art definitions for grid-template-areas [#1](https://github.com/ronilaukkarinen/vscode-stylefmt/issues/1)

## v6.2.1

* Fix: Media queries should be last by default
Expand Down
16 changes: 9 additions & 7 deletions lib/formatDecls.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@ function formatDecls (rule, indent, indentWidth, stylelint) {
decl.prop = decl.raws.before.trim().replace(/\n/g, '') + decl.prop
}

decl.raws.between = ': '
decl.raws.before = declarationEmptyLineBefore(stylelint, decl, indent, indentWidth, isSingleLine)
if (decl.prop !== 'grid-template-areas') {
decl.raws.between = ': '
decl.raws.before = declarationEmptyLineBefore(stylelint, decl, indent, indentWidth, isSingleLine)

if (getProperty(stylelint, 'declaration-colon-space-before')) {
decl.raws.between = declarationColonSpaceBefore(stylelint, decl.raws.between)
}
if (getProperty(stylelint, 'declaration-colon-space-before')) {
decl.raws.between = declarationColonSpaceBefore(stylelint, decl.raws.between)
}

if (getProperty(stylelint, 'declaration-colon-space-after')) {
decl.raws.between = declarationColonSpaceAfter(stylelint, decl.raws.between)
if (getProperty(stylelint, 'declaration-colon-space-after')) {
decl.raws.between = declarationColonSpaceAfter(stylelint, decl.raws.between)
}
}

formatValues(decl, stylelint)
Expand Down
12 changes: 7 additions & 5 deletions lib/formatValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ function formatvalues (decl, stylelint) {
var isString = /^("|').*("|')$/.test(decl.value)
var isFunctionCall = /\w+\(.+\)/.test(decl.value)

if (decl.raws.value) {
if (decl.raws.value && decl.prop !== 'grid-template-areas') {
decl.raws.value.raw = decl.raws.value.raw.trim()
}

if (!isString) {
if (!isString && decl.prop !== 'grid-template-areas') {
decl.value = decl.value.trim().replace(/\s+/g, ' ')
}

Expand Down Expand Up @@ -47,13 +47,15 @@ function formatvalues (decl, stylelint) {
}

if (!isFunctionCall) {
// format math operators before `$` or `(`.
// Format math operators before `$` or `(`.
decl.value = decl.value.replace(/(?!^)[+\-*%](?=\$|\()/g, ' $& ')
// don't format "/" from a "font" shorthand property.

// Don't format "/" from a "font" shorthand property.
if (decl.prop !== 'font') {
decl.value = decl.value.replace(/\/(?=\$|\(|\d)/g, ' $& ')
}
// format "-" if it is between numbers

// Format "-" if it is between numbers
decl.value = decl.value.replace(/\d+-(?=\d)/g, function (value) {
return value.replace(/-/g, ' $& ')
})
Expand Down

0 comments on commit 98f5b71

Please sign in to comment.