vscode: Go to next error/warning/info

I’d love a feature where I could go to the next error in the file I’m in, or in the entire project, but not the next warning/info marker. Currently I have these shortcuts available:

  • editor.action.marker.next
  • editor.action.marker.nextInFiles
  • editor.action.marker.prev
  • editor.action.marker.prevInFiles

I think it’d make a lot of sense to expose similar shortcuts for going to the next error, or the next warning, or the next info, but as separate groups.

Example use case: I have a spell checker and a linter enabled for my project. The linter produces both warnings and errors, and the spell checker produces info markers. I care mostly about linter errors and compiler errors, and when those are fixed I care about spelling errors.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 57
  • Comments: 15

Most upvoted comments

I made a VSCode extension because I’ve also been having trouble with this. https://marketplace.visualstudio.com/items?itemName=yy0931.go-to-next-error

It would be nice if we could define something like this

    {
        "key": "f4",
        "command": "editor.action.marker.next",
        "args": "Error|Warn"
    }

And it would skip the Info markers

FYI you can do F8 to jump next/previous error.

https://marketplace.visualstudio.com/items?itemName=yy0931.go-to-next-error

I tested this extension by @yy0931 and it’s quite good! And very thoughtful to write the full guide. 5 stars! I reckon this issue is ready to be closed for being solved.

I don’t think this needs extra configuration. Why can’t Next/Previous Problem respect the current filter set in the Problems view? Basically if a problem is filtered out, skip it when doing Next Problem keyboard shortcut.

Very sad somebody had to write an extension for this.

It would be much appreciated if it was already a feature of vscode itself

As this issue mentions a spell checker as an example, and I found this thread while dealing with that same issue: here’s another solution. This pertains to Code Spell Checker aka streetsidesoftware.code-spell-checker. It comes with an option diagnosticLevel, which is Information by default, and will subsequently show in the Problems pane and be subject to Go to next error/warning/info commands. The level can be set to Hint, removing the extension’s info from the Problems pane. Go to next error/warning/info then works as expected and doesn’t jump to typos anymore.

This is what the Hint level then looks like (bottom left):

image

So perhaps, as a workaround, see if your extension supports adjusting its reporting level (which doesn’t solve the underlying issue of course, a solution to which I’d still prefer over this approach).

100% agree Or if you can focus on the “error provider” of your choice that will be ideal: just next error coming from eslint, next error coming from typescript, etc.

I don’t think this needs extra configuration. Why can’t Next/Previous Problem respect the current filter set in the Problems view? Basically if a problem is filtered out, skip it when doing Next Problem keyboard shortcut.

That makes a lot of sense

In Jetbrains IDEs “Next Error” loops through all errors across all files, and only when there are no longer any errors, loops through all warnings, etc. I quite like this behaviour and it might address or complement the scenario in this issue.

However it doesn’t appear possible in VsCode:

  • The setting problems.sortOrder = ‘Severity’ will prioritize warnings in the current file over errors in others even when using “Next Problem In Files (Error, Warning)”. Related: https://github.com/microsoft/vscode/issues/135249
  • yy0931’s extension requires binding multiple keys to achieve the same.

My typical scenario: adding a required member to the TS interface of a React component props always causes errors in the parent component files. I’d press {key} to navigate to those right next – which might over multiple files, possibly with warnings – so that I can build again, then keep using {key} to navigate to warnings from the current location.

In short I suggest that when when problems.sortOrder = ‘Severity’:

  • “Next Problem In Files (Error, Warning[, Info])” should prioritize workspace errors above any warnings.
  • “Next Problem (Error, Warning[, Info])” should prioritize current file errors above any warnings. Related: https://github.com/microsoft/vscode/issues/97643