Skip to content

Wrong end position on multiline variables #108

@jwilsson

Description

@jwilsson

Originally reported at lesshint/lesshint#487

  • Node Version: 10.8.0
  • NPM Version: ``
  • postcss-less Version: 2.0.0

If you have a large amount of code to share which demonstrates the problem you're experiencing, please provide a link to your
repository rather than pasting code. Otherwise, please paste relevant short snippets below.

LESS

@var: '
foo
bar
';

JavaScript

const postcss = require('postcss');
const syntax = require('postcss-less');

const lessText = `@var: '
foo
bar
';`;

postcss([])
  .process(lessText, { syntax: syntax })
  .then(function (result) {
    console.log(result.root.first)
});

Expected Behavior

An AST similar to this:

{
  ...
  source: {
    start: { line: 1, column: 1 },
    end: { line: 4, column: 2 }
  }
}

Actual Behavior

An AST looking like this (note the end line):

{
  ...
  source: {
    start: { line: 1, column: 1 },
    end: { line: 1, column: 18 }
  }
}

How can we reproduce the behavior?

Run the JS example above.

The original issue used a tilde-escaped string but I've managed to reproduce it with any multiline variable. I'm not really sure how to solve it, but I'll continue to think about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions