Open trevordixon opened 11 years ago
Ok, so jshint prefs like "indent" should depend on the current buffer's indentation settings.
Yes, I think that's a good solution. If there's no .jshintrc indent option set, set it based on the buffer's indentation settings (1 for tabs or as many spaces as constitute an indent).
+1. Every line being pointed to by Sublime-JSHint was wrong until I switched to spaces. It shouldn't prefer one over the other because they're both valid. Can this be fixed to correctly and automatically detect tabs?
Any progress on this?
To underline the correct word (in my context):
...
regions = []
for err in errs:
line_begin = view.text_point(int(err[1]) - 1, 0)
line_region = view.line(line_begin)
buf = view.substr(line_region)
tab_length = len(re.findall("\t", buf))
isSpacesIndentation = view.settings().get("translate_tabs_to_spaces")
tab_size = 1
if (not isSpacesIndentation):
tab_size = view.settings().get("tab_size")
line = int(err[1]) - 1
col = int(err[2]) - 1 - (tab_size * tab_length) + tab_length
text_point = view.text_point(line, col)
region = view.word(text_point)
regions.append(region)
...
If you go to the error point using the palette, the code above, modified to insert it in the plugin, should work.
Anyway I have a problem with F4, because Sublime does not make the correct calc when it needs to set the cursor; weirdly in the bottom left the column is displayed correctly.
When Sublime uses tabs adding "indent": 1
to .jshintrc
fixes alignment of errors indeed. It would be nice if the plugin did that automatically.
I am sorry for the self promotion: https://sublime.wbond.net/packages/Build%20Next After my previous comment I developed the above plugin.
As you can see in the screenshot, the wrong symbol is underlined. The word "template" should be underlined.
The reason for this is that jshint considers tabs 4 columns wide (https://github.com/jshint/jshint/issues/805), but the
col
parameter in Sublime'stext_point
funtion "is interpreted as the number of characters to advance past the beginning of the row."Setting
"indent": 1
in .jshintrc fixes the problem for me, but it would be better if this worked by default.