Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename happens in wrong location when build has failed #417

Open
Kingdutch opened this issue May 12, 2022 · 6 comments
Open

Rename happens in wrong location when build has failed #417

Kingdutch opened this issue May 12, 2022 · 6 comments

Comments

@Kingdutch
Copy link

It looks like the rename happens based on the last known location for a token. This means that if you create a syntax error in your script and try to rename something, the location of the tokens may be outdated and the new name is inserted in the wrong position.

Video is attached that shows this happening. The syntax error in this case is an unbalanced piece of JSX.

Screen.Recording.2022-05-12.at.11.43.31.mov
@cristianoc
Copy link
Collaborator

Good point. I think rename should not happen when the file is unsaved.
@zth what do you think?

The server already keeps track of the current content of the file. Perhaps the server should also keep track of whether the file is saved.

@zth
Copy link
Collaborator

zth commented May 12, 2022

Yeah, maybe we should prompt the user that the file isn't saved, and then ask them to save it and try again?

@Kingdutch
Copy link
Author

Shouldn't the extension be using the code that's in the editor's memory and not what's on disk? Or is there something that prevents that?

There may be reasons why the user does not want to save.

@cristianoc
Copy link
Collaborator

Shouldn't the extension be using the code that's in the editor's memory and not what's on disk? Or is there something that prevents that?

There may be reasons why the user does not want to save.

Renaming with unsaved files is asking for trouble.

@cristianoc
Copy link
Collaborator

cristianoc commented May 13, 2022

Looks like the server can receive notifications when a file is saved, but a way to "un-save" a file is to use undo, and there's no special notification that helps figuring out the file is not unsaved anymore as far as I can see.

So one might have to take the current file content and compare it with the one on disk. Unclear whether this is best done on the server TS code or on the binary commands.

@zth
Copy link
Collaborator

zth commented May 17, 2022

I guess we'll need to check every file that might be affected by rename, and bail the rename if either of those is unsaved. I think we'll need to mull on this a bit more before going forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants