stylus-supremacy icon indicating copy to clipboard operation
stylus-supremacy copied to clipboard

Comments and empty lines inside object definitions cause harrowing comment weirdness

Open maranomynet opened this issue 5 years ago • 4 comments

namespace = {
    one: 1,
    // A comment (or empty line) inside an object definition triggers weirdness
    two: 2,
}

becomes this:

// A comment (or empty line) inside an object definition triggers weirdness
namespace = {
    one: 1,
    two: 2,
}

But there's more! 😀

If I remove the comment but leave an empty line:

namespace = {
    one: 1,

    two: 2,
}
mixin() {
    // Comment A
    // Comment B
    some: style;
    // Comment C
    // Comment D
}
selector {
    // Comment E
    // Comment F
    some: style;
    // Comment G
    // Comment H
}

Then this happens:

namespace = {
  one: 1,
  two: 2
};

mixin() {
  // Comment A
  some: style;
} // Comment D

selector {
  // Comment E
  some: style;
}

maranomynet avatar Oct 17 '18 13:10 maranomynet

I'm terribly busy this week. Please spare me sometime to fix this. I suspect that this bug has just been introduced in the recent release.

ThisIsManta avatar Oct 17 '18 16:10 ThisIsManta

I've noticed as well if I have comments at the end of the file, they'll get removed completely.

K3TH3R avatar Nov 24 '18 08:11 K3TH3R

Using command line with selectorSeparator=\n

comments at the end of the file are removed:

div
    border 0
// some comment

comments near selectors get removed also

#id
.class // hello there
span
   border 0

weird also with @media and if/else

@media screen // first comment
  if a
    border 0
  else // second comment
    border 20

gives

@media screen
  if a
    border 0
  else
    border 20 // first comment

Comments near if get moved below

if a //comment
  border 0

gives

if a 
  border 0 //comment

keep comment marker gets removed

/*!
 * Some licence
 */

gets transformed to

/*
 * Some licence
 */

notice the ! that disappeared.


Removal of comments in the middle of a file are also a problem

.someClass

  // todo implement this later

.anotherClass
  border 0

transforms to

.someClass
.anotherClass
  border 0

which generates a completely different css


I'll try adding tests in a MR

Cactusbone avatar Oct 08 '19 16:10 Cactusbone

testing @maranomynet example, adding empty lines changes the response until 11 empty lines when no more comments can be seen O_o

2019-10-09_12-16-06

However adding a comment in the middle does not move it up anymore, now it simply disappears

Cactusbone avatar Oct 09 '19 10:10 Cactusbone