Skip to content
This repository was archived by the owner on Apr 1, 2020. It is now read-only.

Add commands to jump to previous/next error #2526

Merged
merged 4 commits into from
Aug 29, 2018
Merged

Conversation

psxpaul
Copy link
Contributor

@psxpaul psxpaul commented Aug 28, 2018

This PR adds oni.editor.nextError and oni.editor.previousError commands, as discussed in #2514. I have mainly tested this with Typescript.

@codecov
Copy link

codecov bot commented Aug 28, 2018

Codecov Report

Merging #2526 into master will increase coverage by 0.85%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2526      +/-   ##
==========================================
+ Coverage   43.57%   44.43%   +0.85%     
==========================================
  Files         351      351              
  Lines       14186    14260      +74     
  Branches     1846     1862      +16     
==========================================
+ Hits         6182     6336     +154     
+ Misses       7767     7697      -70     
+ Partials      237      227      -10
Impacted Files Coverage Δ
browser/src/Services/Diagnostics/index.ts 39.02% <100%> (ø)
browser/src/Plugins/Api/Oni.ts 37.36% <0%> (-4.62%) ⬇️
browser/src/Editor/NeovimEditor/NeovimEditor.tsx 8.84% <0%> (-0.26%) ⬇️
...wser/src/Editor/NeovimEditor/BufferLayerManager.ts 62.96% <0%> (ø) ⬆️
browser/src/Editor/NeovimEditor/HoverRenderer.tsx 26.31% <0%> (ø) ⬆️
browser/src/UI/components/common.ts 92.85% <0%> (+0.12%) ⬆️
.../Services/VersionControl/VersionControlManager.tsx 56.11% <0%> (+0.71%) ⬆️
...ser/src/Editor/NeovimEditor/WelcomeBufferLayer.tsx 53.92% <0%> (+1.64%) ⬆️
browser/src/Services/Language/LanguageStore.ts 97.91% <0%> (+2.08%) ⬆️
...src/Services/Language/LanguageEditorIntegration.ts 86.2% <0%> (+5.17%) ⬆️
... and 19 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e482ae8...ad85587. Read the comment docs.

Copy link
Member

@akinsho akinsho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for this PR @psxpaul much appreciated, I've left a couple of comments let me know what you think

@@ -45,6 +50,78 @@ export const activate = (
const popupMenuPrevious = popupMenuCommand(() => menuManager.previousMenuItem())
const popupMenuSelect = popupMenuCommand(() => menuManager.selectMenuItem())

const gotoNextError = async () => {
Copy link
Member

@akinsho akinsho Aug 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these functions be moved into their own files in the Diagnostics directory maybe Diagnostics/navigateErrors.ts so the global commands isn't where they are implemented and just import them here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I moved this to browser/src/Services/Diagnostics/navigateErrors.ts, but that might be confusing since there's already a browser/src/Services/Diagnostics.ts. I can move that file inside the new browser/src/Services/Diagnostics directory if you want.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could make the already existing Diagnostics.ts => browser/src/Services/Diagnostics/index.ts that way if there are future helpers etc. they can go in the same dir plus you wont have to change any imports since as index all the imports of the file should work as is

const currentFileErrors = getAllErrorsForFile(activeBuffer.filePath, errors)
const currentPosition = activeBuffer.cursor

if (!currentFileErrors || currentFileErrors.length === 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

currentFileErrors.length === 0 could be !currentFileErrors

}
}

activeBuffer.setCursorPosition(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should also be awaited as above I think?

lastError = error
}

activeBuffer.setCursorPosition(lastError.range.start.line, lastError.range.start.character)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if this is async but its likely to be in which case does it need to be awaited since its not being returned to be awaited elsewhere

* Test that you can jump to the next/previous error
*/
import * as assert from "assert"
import * as Oni from "oni-api"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯thanks for adding this

@akinsho
Copy link
Member

akinsho commented Aug 29, 2018

going to merge this now if you're ready @psxpaul? Thanks again 🎉

@akinsho akinsho merged commit a396537 into onivim:master Aug 29, 2018
@akinsho
Copy link
Member

akinsho commented Aug 30, 2018

@psxpaul the commands work like a dream very nice work ⭐️, would you be able to add them to the documentation somewhere under the config section so other users can find them.

@badosu
Copy link
Collaborator

badosu commented Aug 30, 2018

@psxpaul Do you mind adding an entry on the wiki for this?

I fear the lack of default keybindings may make this feature invisible to users.

@psxpaul
Copy link
Contributor Author

psxpaul commented Aug 30, 2018

I've added some bindings to this page, but I'm not sure if that's the best place for it.

@badosu
Copy link
Collaborator

badosu commented Aug 30, 2018

Seems good enough, thanks!

Just noticed me and @Akin909 posted at the same time

@bryphe
Copy link
Member

bryphe commented Sep 1, 2018

Awesome! Been wanting this for a while, very nice work - great test coverage too @psxpaul ! 💯

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants