Skip to content

Commit 4b8b569

Browse files
committed
Do not rename if the operation spans out of the sketch
1 parent bd5ee6b commit 4b8b569

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Diff for: ls/ls.go

+13
Original file line numberDiff line numberDiff line change
@@ -1243,9 +1243,22 @@ func (ls *INOLanguageServer) TextDocumentRenameReqFromIDE(ctx context.Context, l
12431243
logger.Logf("Error: %s", err)
12441244
return nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
12451245
}
1246+
1247+
// Check if all edits belongs to the sketch
1248+
for ideURI := range ideWorkspaceEdit.Changes {
1249+
go ls.showMessage(logger, lsp.MessageTypeError, "Could not rename symbol, it requires changes outside the sketch.")
1250+
if !ls.ideURIIsPartOfTheSketch(ideURI) {
1251+
return nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInvalidParams, Message: "Could not rename symbol, it requires changes outside the sketch."}
1252+
}
1253+
}
12461254
return ideWorkspaceEdit, nil
12471255
}
12481256

1257+
func (ls *INOLanguageServer) ideURIIsPartOfTheSketch(ideURI lsp.DocumentURI) bool {
1258+
res, _ := ideURI.AsPath().IsInsideDir(ls.sketchRoot)
1259+
return res
1260+
}
1261+
12491262
func (ls *INOLanguageServer) ProgressNotifFromClangd(logger jsonrpc.FunctionLogger, progress *lsp.ProgressParams) {
12501263
var token string
12511264
if err := json.Unmarshal(progress.Token, &token); err != nil {

0 commit comments

Comments
 (0)