Skip to content

Commit 753d959

Browse files
committed
fix: handle hover in parameters
1 parent ac9a420 commit 753d959

File tree

1 file changed

+14
-3
lines changed
  • web/src/components/features/workspace/CodeEditor/autocomplete/hover

1 file changed

+14
-3
lines changed

web/src/components/features/workspace/CodeEditor/autocomplete/hover/parse.ts

+14-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,18 @@ const getLineTokens = (str: string, lang: string): monaco.Token[] | null => {
1010
}
1111
}
1212

13-
const checkPackageNameToken = (tokens: monaco.Token[], tokenPos: number) => {
13+
const isDerefOrPtrToken = (line: string, tokens: monaco.Token[], tokenPos: number) => {
14+
const str = tokenToString(line, tokens, tokenPos)
15+
switch (str) {
16+
case '*':
17+
case '&':
18+
return true
19+
default:
20+
return false
21+
}
22+
}
23+
24+
const checkPackageNameToken = (line: string, tokens: monaco.Token[], tokenPos: number) => {
1425
let identPos = -1
1526
let foundIdent = false
1627
let foundDot = false
@@ -28,7 +39,7 @@ const checkPackageNameToken = (tokens: monaco.Token[], tokenPos: number) => {
2839
switch (tok.type) {
2940
case GoToken.Dot:
3041
if (foundDot || foundIdent) {
31-
return -1
42+
return isDerefOrPtrToken(line, tokens, i) && foundIdent ? identPos : -1
3243
}
3344

3445
foundDot = true
@@ -82,7 +93,7 @@ const resolveHoverValue = (line: string, tokens: monaco.Token[], tokenPos: numbe
8293
}
8394

8495
// check if there is a symbol behind to determine direction to move.
85-
const pkgNamePos = checkPackageNameToken(tokens, tokenPos - 1)
96+
const pkgNamePos = checkPackageNameToken(line, tokens, tokenPos - 1)
8697
if (pkgNamePos === -1) {
8798
return { value: hoverValue, range }
8899
}

0 commit comments

Comments
 (0)