-
-
Notifications
You must be signed in to change notification settings - Fork 446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multi-line error highlights make it hard to work #1730
Comments
Sorry for the trouble. I think this is a bug, but on the |
I wonder if we should put a cap on the number of highlighted lines |
Maybe we ought to have a variable at least that says whether to use spans. |
done: tlvince/eslint-plugin-jasmine#230
do you know of any case where highlighting more than 1 line is meaningful? |
Brilliant 👏
Yes, unfortunately; here's an OCaml example where we currently do terrible, and supporting (multi-line) ranges will help (I haven't pushed multi-line support to the flycheck-ocaml checker yet): let f (x: int) =
match x with
| 0 -> "a"
| _ -> (+)
1 3 Right now we highlight the first character of Here's a Coq example showing a similar issue: Definition a :=
True \/
False
:: []. This parses as Which is ill-typed; the error spans the whole But indeed, giant error spans are a problem. In fact, I turned multi-line support off entirely in phpmd because it only highlighted huge spans… Maybe we should find less intrusive ways to report errors, so that it wouldn't be such a problem to develop even with large error spans highlighted. But you seem to have customized flycheck to highlight the text in red in addition to underlining it, which goes against that idea. WDYT? |
After some tests looks like the issue was introduces in 936dbf5#diff-374cdd9563b826c712b1dc6a373a0bc1, before that commit all works good to me |
Can you double-check? I don't think that commit is related. |
Yes I confirm the issue with https://github.com/flycheck/flycheck/blob/936dbf52a223244eee8fe2b26efed4a3b6379331/flycheck.el, Works fine with the previous commit code: https://github.com/flycheck/flycheck/blob/7be341c24a235281ef4e5b87787bff35a23007c6/flycheck.el You can test it with a small code: // date-test.js
/**
* Helper for creating a formatted date string
* @param {date} d Date object
* @param {string} lang Language (only supports English 'en' and Spanish 'es')
* @param {string} timeZone Time zone to use, defaults to America/New_York. Will be ignored in
* unsupported browsers.
* @returns {string} Spanish formatted date (ie: '18 Jul | 06:29 EDT')
*/
export function formatDate(d, lang = 'es', timeZone = 'America/New_York') {
const time = timeZone;
const order = lang;
return `${order} – ${time}`;
} and this eslint plugin: https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/prefer-default-export.md
|
I'm using modus-operandi theme from @protesilaos. I guess the themes could be improved to highlight that there is a problem without making it hard to fix it. |
Thanks for noting this! I will review them right now and report back. EDIT: @DamienCassou I just pushed a commit to |
See this issue: flycheck/flycheck#1730
@vxcamiloxv thanks. As in Damien's case, this is partly an upstream bug: eslint reports a giant error range, so we obediently highlight a giant portion of the buffer. Can you report this issue to the maintainer of the eslint plugin? …but I agree that, in the meantime, we should find a fix, since this isn't very convenient. I can think of a few options:
etc. I'd love to hear ideas and opinions. |
or a combination: underline if the error is on a single line and have markers in case the error spans several lines. Markers have the advantage of allowing multiple errors in the same region such as a small error inside an error spanning several lines. |
@cpitclaudel I'll report the bug also to the upstream eslint plugin |
Hi all, I've made a bit of progress on this. Here are some mock-ups: The idea would be to show regular underlines + fringe indicators up to a configurable number of lines, and then switch to paired delimiters + fringe indicators for longer errors. Now I need to pick a default delimiter and fringe style. Do you have preferences among the above? |
@cpitclaudel In terms of UX, don't you think it could be distracting/annoying to have delimiters shown in the code, as they will move text horizontally on the line? |
@NicolasPetton Definitely, yes. Especially with transient errors that appear and disappear as you type. From my experience programming with it for a few hours, the most annoying part is the start marker, because that moves the place where the point is as well (whereas the end of the error tends to be after the point). On the other hand, it's quite nice to see nested errors. Can you think of something else that would be more discrete? (I'm fairly happy with the continuation lines in the fringe, but I don't think these are enough on their own). |
Also, thanks for having a look! |
Thank you very much for your work. Isn't it the responsibility of the theme to decide how to show something? |
What about simply underlining the first line? With the indications in the fringe, wouldn't it be enough? |
I don't think Emacs themes have this level of control, and in any case we need to come up with good defaults. But in any case, this stuff would be configurable. |
Interesting. That's a heavier change because we'd need two overlays instead of one, but we could do that. That being said, there's still the problem of indicating the end of the error. |
A theme is supposed to control the "faces" themselves ( |
What about showing the full error span only for the currently highlighted error (the one that triggered |
When I'm typing text with a fast-enough checker parts of the current line are often highlighted, so I worry that this too will cause issues. |
Do we really have to? |
Good question. I don't have a very strong opinion. It can help to see where the error ends, but if it messes up the layout it might not be worth it. |
OK, I've cleaned up my branch and added documentation. Please see this PR: #1743. It would be great if you could have a look and ideally give it a try (comments on the design are also very welcome). I've defaulted to hiding underlines when the error spans more than 4 lines. The threshold is customizable and delimiters can be added if desired. |
Checklist
Bug description
It's not a bug, rather an annoying feature.
Flycheck correctly marks the code above as being problematic. Eslint complains similarly:
The jasmine/no-focused-tests rule discourages the use of
fdescribe()
unless during development. Because everything is underlined in flycheck now, usingfdescribe()
becomes nearly impossible even during development.Expected behavior
I think the previous behavior of only marking the first letter of
fdescribe
was more usable.System configuration
Emacs configuration:
The text was updated successfully, but these errors were encountered: