AriaMinaei / pretty-error

See node.js errors with less clutter
MIT License
1.52k stars 49 forks source link

When inline element is null styles are still applied? #24

Closed reggi closed 8 years ago

reggi commented 9 years ago

In my append style I have the trace for what and footer > addr both set to marginLeft:1.

  'pretty-error > 
trace > item > header > what': _.defaults({
    marginLeft: 1
  }, nullStyle),
  'pretty-error > trace > item > footer': _.defaults({
  }, nullStyle),
  'pretty-error > trace > item > footer > addr': _.defaults({
    marginLeft: 1
  }, nullStyle),

You can see the last line in the trace doesn't have a what element.

      {
        "item": {
          "header": {
            "pointer": {
              "file": "node.js",
              "colon": ":",
              "line": 953
            },
            "what": null
          },
          "footer": {
            "addr": "node.js:953:3"
          }
        }
      }

However the on last line, after the bullet there are two spaces instead of one.

Error: Some error message
    at Object.<anonymous> /Users/thomas/Desktop/node-reggi/z-multi-line.js:57:9
    at Module._compile module.js:430:26
    at Object.Module._extensions..js module.js:448:10
    at Module.load module.js:355:32
    at Function.Module._load module.js:310:12
    at Function.Module.runMain module.js:471:10
    at startup node.js:117:18
    at  node.js:953:3

This is unexpected behavior. Without both of these margins set there is no space after the at bullet.

I simply want to output:

Error: Some error message
    at Object.<anonymous> /Users/thomas/Desktop/node-reggi/z-multi-line.js:57:9
    at Module._compile module.js:430:26
    at Object.Module._extensions..js module.js:448:10
    at Module.load module.js:355:32
    at Function.Module._load module.js:310:12
    at Function.Module.runMain module.js:471:10
    at startup node.js:117:18
    at node.js:953:3
reggi commented 9 years ago

Got it working with paddingLeft on what.

  'pretty-error > trace > item > header > what': _.defaults({
    paddingLeft: 1
  }, nullStyle),
  'pretty-error > trace > item > footer': _.defaults({
  }, nullStyle),
  'pretty-error > trace > item > footer > addr': _.defaults({

  }, nullStyle),
reggi commented 9 years ago

Nope false alarm, still can't get it to work :(

AriaMinaei commented 9 years ago

Looks like a renderkid bug. Thanks for reporting it! I'll start working on it this week.

AriaMinaei commented 9 years ago

Okay, so this is not a renderkid bug.

The "what": null means that we do have a <what></what> tag in our markup, so renderkid correctly tries to render that tag, along with its padding/margin. It just doesn't have any children, so we only see its margin taking up space.

We can fix this simply by removing the <what> tag.

AriaMinaei commented 9 years ago

Okay. I've pushed a change. Can you clone from repo and see if it fixes the problem?

AriaMinaei commented 8 years ago

Closing for inactivity. Commit 886fc30 likely does fix the issue, but I can't confirm that. Feel free to open this again if the problem persists.