noseglid / atom-build

:hammer: Build your project directly from the Atom editor
https://atom.io/packages/build
MIT License
248 stars 97 forks source link

Build reports zero-width range when linting lines with errors #526

Open tuxmark5 opened 7 years ago

tuxmark5 commented 7 years ago

Build reports zero-width range when linting lines with errors. This causes linter not to underline the lines that contain errors and only a hard to see red dot. It would be nice if build could provide the range [[row, 0], [row, Infinity]] so the whole line with an error is easily visible.

Example screenshot: 2017-06-30-010444_869x460_scrot

nevercast commented 6 years ago

I'm having this issue also using the custom error matching. AtomLinter does not give tooltips because of the 0 length.

The issue is this line: https://github.com/noseglid/atom-build/blob/master/lib/linter-integration.js#L17

Couple options.

1

    function extractRange(json) {
      return [
        [ (json.line || 1) - 1, (json.col || 1) - 1 ],
        [ (json.line_end || json.line || 1) - 1, (json.col_end || Infinity) - 1 ]
      ];
    }

This is as @tuxmark5 suggests, and will highlight the remainder of the line. image

2

    function extractRange(json) {
      return [
        [ (json.line || 1) - 1, (json.col || 1) - 1 ],
        [ (json.line_end || json.line || 1) - 1, (json.col_end || ((json.col || 1) + 1)) - 1 ]
      ];
    }

This code didn't actually work as expected, but the intention was to highlight only the first character.

I'm not sure which implementation the community or contributors desire but having 0 length ranges is not the right answer.

I can throw together a PR if someone wishes but I've no interest in becoming a maintainer unfortunately.