nscaife / linter-chktex

An Atom Linter plugin for LaTeX, using chktex
https://atom.io/packages/linter-chktex
MIT License
14 stars 10 forks source link

NaN error from user regex warnings #20

Closed NathanJang closed 8 years ago

NathanJang commented 8 years ago

When editing my ia.tex document and using linter-chktex, I saw some strange behaviour in the issues panel at the bottom of the window (if that's what you call it). The indicator showed multiple issues, but only displayed them when I clicked on the "Project" button, but the issues pointed to the file I was editing, but displayed NaN for column numbers.

screen shot 2015-11-11 at 08 21 11

After that, I toggled the linter from the command palette and toggled it back on again. This is when I saw this error.

Some empty tabs also appeared to be opened in the background with a similar name (ia.tex:163:1 as the tab name).

screen shot 2015-11-11 at 10 49 34

Please advise whether this should be reported to the linter package itself.

In the meantime, I'm suppressing user warnings (-n44 in the package setting's args).

Thanks for maintaining this package nonetheless :blush:

chktex output

Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 136: User Regex: -2:Vertical rules in tables are ugly.
\begin{tabular}{| c | c |}  
^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 138: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 140: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 142: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 157: User Regex: -2:Vertical rules in tables are ugly.
\begin{tabular}{| c | c |}  
^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 159: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 161: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 163: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 175: User Regex: -2:Vertical rules in tables are ugly.
\begin{tabular}{| c | c |}  
^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 177: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 179: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^
Warning 44 in /Users/jonchan/Documents/ia/ia.tex line 181: User Regex: -2:Use \toprule, midrule, or \bottomrule from booktabs.
\hline  
^^^^^^

Atom Version: 1.1.0 System: Mac OS X 10.11.1 Thrown From: linter package, v1.10.0

Stack Trace

Uncaught TypeError: Invalid Point: (25, NaN)

At /Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/point.js:65

TypeError: Invalid Point: (25, NaN)
  at Function.module.exports.Point.assertValid (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/point.js:65:15)
  at TextBuffer.module.exports.TextBuffer.clipPosition (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:980:13)
  at TextBuffer.module.exports.TextBuffer.clipRange (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:968:20)
  at TextBuffer.module.exports.TextBuffer.markRange (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/text-buffer/lib/text-buffer.js:693:46)
  at DisplayBuffer.module.exports.DisplayBuffer.markBufferRange (/Applications/Atom.app/Contents/Resources/app.asar/src/display-buffer.js:982:41)
  at TextEditor.module.exports.TextEditor.markBufferRange (/Applications/Atom.app/Contents/Resources/app.asar/src/text-editor.js:1215:59)
  at /Users/jonchan/.atom/packages/linter/lib/editor-linter.js:70:33
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:86:11)
  at EditorLinter.addMessage (/Users/jonchan/.atom/packages/linter/lib/editor-linter.js:150:22)
  at /Users/jonchan/.atom/packages/linter/lib/linter-views.js:147:24
  at Array.forEach (native)
  at LinterViews.notifyEditorLinters (/Users/jonchan/.atom/packages/linter/lib/linter-views.js:145:13)
  at LinterViews.render (/Users/jonchan/.atom/packages/linter/lib/linter-views.js:91:12)
  at /Users/jonchan/.atom/packages/linter/lib/linter.coffee:29:14
  at Emitter.module.exports.Emitter.emit (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/event-kit/lib/emitter.js:86:11)
  at MessageRegistry.updatePublic (/Users/jonchan/.atom/packages/linter/lib/message-registry.js:118:20)
  at UpdateMessages (/Users/jonchan/.atom/packages/linter/lib/message-registry.js:35:17)

Commands

     -0:27.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:27.4.0 linter:toggle (atom-text-editor.editor)
     -0:17.2.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:16.8.0 core:move-down (atom-text-editor.editor.is-focused)
     -0:15.1.0 core:backspace (atom-text-editor.editor.is-focused)
     -0:13.8.0 core:save (atom-text-editor.editor.is-focused)
     -0:12.1.0 latex:build (atom-text-editor.editor.is-focused)
     -0:10 command-palette:toggle (atom-text-editor.editor.is-focused)
     -0:07.5.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:07.4.0 linter:lint (atom-text-editor.editor)
     -0:06.3.0 spell-check:correct-misspelling (atom-text-editor.editor.is-focused)
  2x -0:05.3.0 editor:split-selections-into-lines (atom-text-editor.editor.is-focused)
     -0:04.1.0 command-palette:toggle (atom-text-editor.editor.is-focused)
     -0:01.8.0 core:move-down (atom-text-editor.editor.mini.is-focused)
     -0:01.4.0 core:confirm (atom-text-editor.editor.mini.is-focused)
     -0:01.4.0 linter:toggle (atom-text-editor.editor)

Config

{
  "core": {
    "projectHome": "/Users/jonchan/Developer/Private"
  },
  "linter": {}
}

Installed Packages

# User
Sublime-Style-Column-Selection, v1.3.0
auto-detect-indentation, v0.4.2
language-diff, v0.3.1
language-latex, v0.6.1
latex, v0.28.2
linter, v1.10.0
linter-chktex, v1.2.3
linter-jshint, v1.2.1
minimap, v4.16.0
set-syntax, v0.3.0

# Dev
No dev packages
ghost commented 8 years ago

I am seeing the same errors with this same issue. Definitely a strange one, I see identical line number references.

screen shot 2015-12-30 at 8 49 44 pm
edwinksl commented 8 years ago

Yeah I see the same NaN errors in the column numbers. Not sure how to resolve them except to turn off user warnings.

nscaife commented 8 years ago

Does this happen on every document? I'm not able to reproduce it. Can you provide a minimal .tex example so I can try to figure out what is going on?

edwinksl commented 8 years ago

@nscaife, the NaN errors come from using the float table environment. A somewhat minimal code that reproduces the errors is:

\documentclass{article}

\begin{document}

\begin{table}
\centering
  \begin{tabular}{|c|}
  \hline
  Test \\
  \hline
  \end{tabular}
\end{table}

\end{document}

The warnings that chktex generates are: chktex

nscaife commented 8 years ago

@edwinksl Thanks for sending the sample! It looks like this problem was caused by an error in my regex for parsing the chktex output. I've published a patch, can you test it and verify that it solves your issue?

NathanJang commented 8 years ago

@nscaife It no longer shows NaN on @edwinksl's minimal sample. Can anyone else confirm?

edwinksl commented 8 years ago

@nscaife @NathanJang I can confirm the NaN errors are gone. Thanks!

nscaife commented 8 years ago

Great! Sorry it took so long to fix!

NathanJang commented 8 years ago

Thanks @nscaife!