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

fix: hover on incorrect node #28

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Jeansidharta
Copy link
Contributor

@Jeansidharta Jeansidharta commented Dec 16, 2023

Bug description

When hovering on the first letter of an identifier, it`d often show nothing.

Steps to reproduce

  1. Create a new scad file
  2. open it in your editor, and write
batata = 10;
cube(batata);
  1. Hover on the first letter of the word batata.

Tested on Neovim v0.9.4

Logs

Here are my LSP logs for the request/response:

[DEBUG][2023-12-16 00:30:19] .../vim/lsp/rpc.lua:284    "rpc.send"      {
  id = 3,
  jsonrpc = "2.0",
  method = "textDocument/hover",
  params = {
    position = {
      character = 5,
      line = 1
    },
    textDocument = {
      uri = "file:///home/username/batata.scad"
    }
  }
}
[DEBUG][2023-12-16 00:30:19] .../vim/lsp/rpc.lua:387    "rpc.receive"   {
  id = 3,
  jsonrpc = "2.0"
}

The solution ?

I have no idea why this is happening. The tree_sitter function goto_first_child_for_point (docs) is simply returning earlier than it should for the Point. My solution is just a simple hack that should fix most/all cases

@Jeansidharta Jeansidharta force-pushed the fix/incorrect-hover-position branch from 37bacbc to 7b7e75e Compare December 16, 2023 05:49
@Leathong
Copy link
Owner

Leathong commented Jan 12, 2024

I test it on VSCode on Mac, and can't reproduce it.

@Lenbok
Copy link
Contributor

Lenbok commented Jan 18, 2024

I am using emacs lsp-mode and see the same behaviour as @Jeansidharta (using openscad-lsp v1.2.5). Put your cursor on the cube([b]atata) and no hover shows (and you also cannot jump to definition). Move one character to the right (cube(b[a]tata)) and both hover and jump to defn work fine.

If you instead have cube(size = batata);, having cursor on the first b works just fine.

@Leathong
Copy link
Owner

I reproduced this bug, but it has little impact on usage. This workaround maybe cause other problem, so I won't merge it for now.

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

Successfully merging this pull request may close these issues.

3 participants