Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Documentation pops up inappropriately and doesn't go away #2481

Closed
kentquirk opened this issue Apr 28, 2019 · 16 comments
Closed

Documentation pops up inappropriately and doesn't go away #2481

kentquirk opened this issue Apr 28, 2019 · 16 comments

Comments

@kentquirk
Copy link
Contributor

kentquirk commented Apr 28, 2019

(I should note that I am not using go modules yet and I am not using the language server.)

Steps to Reproduce:

  1. Enter this code into a new project:
package main

import (
	"fmt"
	"regexp"
)

func main() {
	data := []byte("123abc")
	x, err := regexp.Match("abc", data)
	if err != nil {
		// we had an error
	}
	fmt.Println(x)
}
  1. Place cursor at the end of the word "error" in the comment
  2. Type a comma (',')

Result:
The documentation pops up for Match; it's not appropriate here (we're not inside the Match parentheses).

image

Part 2:
Press enter and type fmt.Println("foo"). Note that the documentation box is present while you're typing, and changes to Println while you're inside the parentheses, but that it changes back to Match after you hit ')'.

It won't go away as you type move the cursor around until you cross the boundary of another function call. The only way to get rid of it entirely is to hit escape.

image

What I expected:

  • entering comments should not invoke the popup at all
  • editing function calls should only pop up the documentation while the cursor is within the parentheses
  • closing the parentheses should cause the documentation box to close
@zlier233
Copy link

Wow I had the same problem with u. And it almost kill me!!!! Hope to find a way to solve it

@zlier233
Copy link

And I found a temporary way to fix it. Change the "doc tool" setting to "gogetdoc" or "guru" and do not install it. But at the same time u will lost the function/method hint.

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @kentquirk and @ZeroZ233

cc @lggomez, @vladbarosan, @jhendrixMSFT This probably is an after affect of the changes that went in as part of #1738 as we don't see this behavior in the older versions of the extension.

PRs are most welcome to fix this bug
Code pointers:

  • Build and Debug extension
  • File where the fix should be made: goSignature.ts
  • Function in the above file that needs to be fixed (most probably): walkBackwardsToBeginningOfCall

@kentquirk
Copy link
Contributor Author

Thanks for the pointer. I'll try to take a look in the next day or two (but if someone else wants it, feel free!)

@section14
Copy link

+1

I'm hitting escape non-stop to get rid of the code hints. Windows 10, VSCode 1.331, Go extension 0.10.1

@lggomez
Copy link
Contributor

lggomez commented May 3, 2019

It looks broken on two fronts:

  • Failing to detect a previous and closed function boundary, thus triggering a completion for that function scope
  • Completions are being triggered on comments and comment blocks (this is serious, although it may just be a consequence of the previous bug on this specific example)

The later can be harder to tackle since it needs extra work, #1116 approached it for general code completions, the general gist of it should still be applicable to this

I will try to take a look but I'm on a limited schedule; I can provide help to whoever is already working on this (if someone already is)

@ramya-rao-a
Copy link
Contributor

Thanks @lggomez
I'll loop you in as a reviewer if any one submits a PR to fix this

Regarding comments
We can always check if the current line is a line comment (look for // before the current position), but checking whether current line is part of a block comment is expensive and I wouldnt suggest going down that route as that can get expensive

@lggomez
Copy link
Contributor

lggomez commented May 5, 2019

Apparently ignoring the comment fixes part 2 of the issue. On the contrary of my previous comment, the main issue might be the comments being processed, which causes unexpected behavior on following lines

I pushed #2496 with a potential fix containing this check. PTAL @ramya-rao-a

@ZeroZ233 @section14 you should be able to test this by cloning the repo and using the "Launch extension" debug launch configuration. If you otherwise need a compiled version I can provide one

@lggomez
Copy link
Contributor

lggomez commented May 7, 2019

It still happens with the basic comment check so there is still something else to be fixed on the comma backtracking

@ramya-rao-a
Copy link
Contributor

This should be fixed with the latest changes from @lggomez
Please try the latest beta version of this extension

@jborlum
Copy link

jborlum commented May 7, 2019

This should be fixed with the latest changes from @lggomez
Please try the latest beta version of this extension

I've been unable to install this on macos. Shouldn't it work the same as on Windows?

@ramya-rao-a
Copy link
Contributor

I am able to install it on my Mac without any issues. What errors are you seeing and at what step?

@jborlum
Copy link

jborlum commented May 9, 2019

It's a good question. When running 'code --install-extension Go-0.10.3-beta.1.vsix' it completes fine, but when I check the installed gocode plugin it is still using the latest release.

@ramya-rao-a
Copy link
Contributor

Try the Extensions: Install from VSIX command and make sure to reload the VS Code window

@jborlum
Copy link

jborlum commented May 10, 2019

That worked. Thank you Ramya!

@ramya-rao-a
Copy link
Contributor

This bug fix is now available in the latest update (0.11.0) to the Go extension. Thanks @lggomez!

@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants