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

Replacing a variable's name with "replace in files" causes some of the code I wrote before to disappear #91406

Open
FakerDomain opened this issue May 1, 2024 · 3 comments

Comments

@FakerDomain
Copy link

FakerDomain commented May 1, 2024

Tested versions

4.2.2 stable

System information

Windows10

Issue description

When I use the ctrl+alt+F to replace a variable's name, some of the code I wrote before using the replace function in the currently open script disappears directly

Steps to reproduce

  1. create a script, and add some code like below:
extends Node

var g_test: int
var b_test: int

func start() -> void:
	if g_test:
		print(g_test)
  1. write some additional code below the 'star()' function, any code (or comments), it doesn't matter,
  2. press ctrl+alt+F to replace for example, 'g_test' with 'a_test' and chose to replace them all.
  3. then, what you just write in the 2th step will disappear~

Minimal reproduction project (MRP)

N/A

@fire fire changed the title There is an extremely serious problem with the replacement function!!!!!! Replacing a variable's name with Ctrl+Alt+F causes some of the code I wrote before to disappears May 1, 2024
@fire fire changed the title Replacing a variable's name with Ctrl+Alt+F causes some of the code I wrote before to disappears Replacing a variable's name with Ctrl+Alt+F causes some of the code I wrote before to disappear May 1, 2024
@ArchieVillain
Copy link

When you say CTRL+ALT+F, do you mean "Replace in Files"? Because that is bound to CTRL+SHIFT+R by default, with CTRL+ALT+F bringing up the "Jump to Function" modal, which doesn't seem to allow for any replacements.

Regardless, I was able to reproduce the issue with "Replace in Files". As the name implies, it looks for the provided text in the actual source files, while "Replace" looks at the contents of the text editor. This means that any replacement done with "Replace in Files" is going to result in a reload request from editor as the file is newer on disk. If you have any unsaved changes in the editor, they will be lost in the reload.

Can you confirm that the issue doesn't present itself if you save all changes before executing the replacement routine?

@FakerDomain
Copy link
Author

When you say CTRL+ALT+F, do you mean "Replace in Files"? Because that is bound to CTRL+SHIFT+R by default, with CTRL+ALT+F bringing up the "Jump to Function" modal, which doesn't seem to allow for any replacements.

Regardless, I was able to reproduce the issue with "Replace in Files". As the name implies, it looks for the provided text in the actual source files, while "Replace" looks at the contents of the text editor. This means that any replacement done with "Replace in Files" is going to result in a reload request from editor as the file is newer on disk. If you have any unsaved changes in the editor, they will be lost in the reload.

Can you confirm that the issue doesn't present itself if you save all changes before executing the replacement routine?

Yeah, you are right, I mean Ctrl+Shift+F. And I tried what you mentioned, my code won't disappear anymore if I saved the script before I replace something. However, I still wish my script can be saved automatically when I use the replacement function, since last time my code (a lot of code) disappeared, which made me very frustrated!

@ArchieVillain
Copy link

You may want to throw your support behind this proposal: godotengine/godot-proposals#9654.

@AThousandShips AThousandShips changed the title Replacing a variable's name with Ctrl+Alt+F causes some of the code I wrote before to disappear Replacing a variable's name with "replace in files" causes some of the code I wrote before to disappear May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants