Skip to content
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

Goto Definition is off by one #154

Open
m0rphism opened this issue Jul 15, 2024 · 3 comments
Open

Goto Definition is off by one #154

m0rphism opened this issue Jul 15, 2024 · 3 comments

Comments

@m0rphism
Copy link

m0rphism commented Jul 15, 2024

Consider the following code:

open import Data.Nat
                -- cursor jumps to this line
x :-- cursor should jump to this line
x = {! !}

y = x           -- cursor is on this x when running GotoDefinition

If using CornelisGotoDefinition on the x in the definition of y, then the cursor jumps not to the line with x : ℕ, but to the empty line above it. This seems to happen independently of what code is around the definition and how far the uses and definitions are apart from each other.

Thanks for the great plugin! <3

I'm currently switching from emacs to nvim, and apart from #153 and #121 this plugin seems to have everything I need. Keep up the great work! :)

@isovector
Copy link
Owner

Weird. This is definitely a regression, but I can indeed reproduce it 😕

I'm not actively writing any Agda these days, so it might take some time to tackle this one.

@isovector
Copy link
Owner

This is almost certainly the problem:

let buffer_idx = toBytes contents $ zeroIndex $ ds_position ds

which a quick fix might be

      let buffer_idx = toBytes contents $ incIndex $ zeroIndex $ ds_position ds

The vim API has at least four different indexing modes, and it's hard to make sure we pick the right one in each case :(

m0rphism added a commit to m0rphism/cornelis that referenced this issue Jul 15, 2024
@m0rphism
Copy link
Author

m0rphism commented Jul 15, 2024

Nice! I just tested it in a fork, and it indeed fixes the bug. 👍

Thanks for the quick help! 👏

The vim API has at least four different indexing modes, and it's hard to make sure we pick the right one in each case :(

Yeah, I can imagine... I yet have to find a text editor API, which doesn't make me want to pull my hair out ;)

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

No branches or pull requests

2 participants