Skip to content

Commit

Permalink
Fix rename for new AST
Browse files Browse the repository at this point in the history
  • Loading branch information
kralicky committed Aug 18, 2024
1 parent efac89a commit 8bbf446
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/lsp/rename.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (c *Cache) Rename(params *protocol.RenameParams) (*protocol.WorkspaceEdit,

editsByDocument := map[protocol.DocumentURI][]protocol.TextEdit{}
for _, ref := range append(refs, definition) {
node := ref.Node
node := ast.Unwrap(ref.Node)
// only edit the short name, not the qualified name (if it is qualified)
// we can do this adjustment using only the range
var editRange ast.SourceSpan
Expand Down Expand Up @@ -170,6 +170,8 @@ func (c *Cache) Rename(params *protocol.RenameParams) (*protocol.WorkspaceEdit,
editRange = ref.NodeInfo.Internal().ParentFile().NodeInfo(node.Name)
case *ast.RPCNode:
editRange = ref.NodeInfo.Internal().ParentFile().NodeInfo(node.Name)
case *ast.RPCTypeNode:
editRange = ref.NodeInfo.Internal().ParentFile().NodeInfo(node.MessageType)
default:
return nil, fmt.Errorf("cannot rename %T", node)
}
Expand Down

0 comments on commit 8bbf446

Please sign in to comment.