-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/govim: place signs for existing diagnostics in new buffers (#590)
If gopls report diagnostics for files that aren't opened in vim they won't get any signs placed when they are opened. A typical use case is when staticcheck report diagnostics for a file that isn't opened, and the user uses quickfix to jump directly to the issue (effectively opening a new buffer). This change updates the internal diagnostics cache when a buffer is read or closed so existing diagnostics will have signs placed.
- Loading branch information
Showing
8 changed files
with
91 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
cmd/govim/testdata/scenario_default/signs_existing_diags.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Test that signs are placed when opening a file that already has diagnostics. | ||
vim ex 'e main.go' | ||
errlogmatch -wait 30s 'sendJSONMsg: .*\"call\",\"s:batchCall\",.*\"sign_placelist\"' | ||
vim ex 'e other.go' | ||
errlogmatch -wait 30s 'sendJSONMsg: .*\"call\",\"s:batchCall\",.*\"sign_placelist\"' | ||
vim -indent expr 'sign_getplaced(\"other.go\", {\"group\": \"*\"})' | ||
! stderr .+ | ||
cmp stdout placed.golden | ||
# Disabled pending resolution to https://github.com/golang/go/issues/34103 | ||
# errlogmatch -count=0 'LogMessage callback: &protocol\.LogMessageParams\{Type:(1|2), Message:".*' | ||
|
||
-- go.mod -- | ||
module mod.com | ||
|
||
-- main.go -- | ||
package main | ||
|
||
func main() { | ||
var z int | ||
z = z | ||
} | ||
-- other.go -- | ||
package main | ||
|
||
import "fmt" | ||
|
||
func foo() { | ||
fmt.Printf("%v") | ||
} | ||
|
||
-- placed.golden -- | ||
[ | ||
{ | ||
"bufnr": 2, | ||
"signs": [ | ||
{ | ||
"group": "govim", | ||
"id": 1, | ||
"lnum": 6, | ||
"name": "govimWarnSign", | ||
"priority": 12 | ||
} | ||
] | ||
} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters