Skip to content
This repository has been archived by the owner on Nov 5, 2021. It is now read-only.

Add a rename provider #39

Merged
merged 1 commit into from Sep 19, 2019
Merged

Conversation

spahnke
Copy link
Contributor

@spahnke spahnke commented Aug 14, 2019

This PR registers a monaco.languages.RenameProvider with the Monaco Editor for a safe way of renaming symbols. Feedback/recommendations welcome!

Fixes microsoft/monaco-editor#300

The rename operations currently suffer from the same problem as code actions and cannot be undone (see microsoft/monaco-editor#1548).

I also get the following warning on the browser console after the rename operation is applied. Any suggestions for the cause of that? (Monaco version 0.17.1)
grafik

Thanks!


// --- rename ----

export class RenameAdapter extends Adapter implements monaco.languages.RenameProvider {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another optional method resolveRenameLocation in the interface which I didn't implement. What is the purpose of this method and do we need that?

if (!(renameLocation.fileName in fileNameToResourceTextEditMap)) {
const resourceTextEdit = {
edits: [],
resource: monaco.Uri.parse(renameLocation.fileName)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot use monaco.Uri.file here; it leads to the error "bad edit - model not found".

Copy link
Contributor

@orta orta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just tested this locally, and it works fine - I don't get the same stack trace:

2019-08-29 14-06-14 2019-08-29 14_08_35

@alexdima
Copy link
Member

Thank you! ❤️

@alexdima alexdima merged commit 7d4d30f into microsoft:master Sep 19, 2019
@alexdima alexdima added this to the August 2019 milestone Sep 19, 2019
@spahnke spahnke deleted the rename-provider branch September 19, 2019 11:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants