Skip to content

Commit e34d2ca

Browse files
committed
Properly handle hovering on this
1 parent 8bf36dd commit e34d2ca

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

internal/ls/hover.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ func formatQuickInfo(quickInfo string) string {
108108
}
109109

110110
func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol, node *ast.Node) (string, *ast.Node) {
111+
container := getContainerNode(node)
112+
if node.Kind == ast.KindThisKeyword && ast.IsInExpressionContext(node) {
113+
return c.TypeToStringEx(c.GetTypeAtLocation(node), container, typeFormatFlags), nil
114+
}
111115
isAlias := symbol != nil && symbol.Flags&ast.SymbolFlagsAlias != 0
112116
if isAlias {
113117
symbol = c.GetAliasedSymbol(symbol)
@@ -129,7 +133,6 @@ func getQuickInfoAndDeclarationAtLocation(c *checker.Checker, symbol *ast.Symbol
129133
// If the symbol has a type meaning and we're in a type context, remove value-only meanings
130134
flags &^= ast.SymbolFlagsVariable | ast.SymbolFlagsFunction
131135
}
132-
container := getContainerNode(node)
133136
var b strings.Builder
134137
if isAlias {
135138
b.WriteString("(alias) ")

0 commit comments

Comments
 (0)