Skip to content

Commit

Permalink
Fixed "@block" issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Anantachai Saothong (Manta) committed Apr 19, 2017
1 parent 99516f6 commit bf94e53
Show file tree
Hide file tree
Showing 8 changed files with 8 additions and 34 deletions.
4 changes: 2 additions & 2 deletions edge/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ function format(content, options) {
} else if (inputNode instanceof stylus.nodes.Root || inputNode instanceof stylus.nodes.Block) {
const childIndentLevel = inputNode instanceof stylus.nodes.Root ? 0 : (indentLevel + 1)

if (inputNode instanceof stylus.nodes.Block && options.insertBraces) {
if (inputNode instanceof stylus.nodes.Block && (parentNode instanceof stylus.nodes.Atblock ? options.alwaysUseAtBlock : options.insertBraces)) {
outputBuffer.append(' {')
}

Expand Down Expand Up @@ -252,7 +252,7 @@ function format(content, options) {
outputBuffer.append(bottomCommentNodes.map(node => travel(inputNode.parent, node, childIndentLevel)).join(''))
}

if (inputNode instanceof stylus.nodes.Block && options.insertBraces) {
if (inputNode instanceof stylus.nodes.Block && (parentNode instanceof stylus.nodes.Atblock ? options.alwaysUseAtBlock : options.insertBraces)) {
outputBuffer.append(indent + '}')
outputBuffer.append(options.newLineChar)
}
Expand Down
3 changes: 0 additions & 3 deletions spec/block/formattingOptions.json

This file was deleted.

10 changes: 0 additions & 10 deletions spec/block/input.styl

This file was deleted.

11 changes: 0 additions & 11 deletions spec/block/output.styl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"alwaysUseAtBlock": false,
"insertBraces": true,
"newLineChar": "\r\n"
}
6 changes: 2 additions & 4 deletions spec/option-always-use-at-block-false/output.styl
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
foo = {
foo =
width: 20px;
}
bar = {
bar =
height: 30px;
}

.class1 {
{foo};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"alwaysUseAtBlock": true,
"alwaysUseAtBlock": true,
"insertBraces": false,
"newLineChar": "\r\n"
}
5 changes: 2 additions & 3 deletions spec/option-always-use-at-block-true/output.styl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ bar = @block {
height: 30px;
}

.class1 {
.class1
{foo};
{bar};
}
{bar};

0 comments on commit bf94e53

Please sign in to comment.