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

Allow removing files in the file search #82629

Closed
wants to merge 1 commit into from

Conversation

Stronkkey
Copy link

@Stronkkey Stronkkey commented Oct 1, 2023

@Stronkkey Stronkkey requested a review from a team as a code owner October 1, 2023 17:05
@Chaosus Chaosus added this to the 4.2 milestone Oct 2, 2023
@Stronkkey Stronkkey changed the title Adds the ability to remove files when using file search Add the ability to remove files when using file search Oct 2, 2023
@Stronkkey Stronkkey force-pushed the remove_entries branch 2 times, most recently from a8e9a72 to 531676b Compare October 2, 2023 09:21
@Stronkkey Stronkkey changed the title Add the ability to remove files when using file search Allowing removing files in the file search Oct 3, 2023
editor/find_in_files.cpp Outdated Show resolved Hide resolved
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased on top of bfd78bb), it works as expected.

Replace in Files also takes deleted entries into account:

image

Result:

image

The icon design should be changed though, as it doesn't fit well with the rest of the engine's visual design currently (see review comment).

@Stronkkey Stronkkey changed the title Allowing removing files in the file search Allow removing files in the file search Oct 5, 2023
@Stronkkey
Copy link
Author

Is the new version good?

@Stronkkey Stronkkey requested a review from Calinou October 6, 2023 18:29
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Looks great now!

image

editor/find_in_files.cpp Outdated Show resolved Hide resolved
@akien-mga
Copy link
Member

It may look nicer if the button was added on hover only, like in VS Code in KoBeWi's proposal. But if that requires making the implementation significantly more complex, then it's probably not worth it.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 9, 2023

Another thing is that in VS Code deleting a result will update the number:

Code_sNIFvD4Ng4.mp4

editor/find_in_files.cpp Outdated Show resolved Hide resolved
@Stronkkey Stronkkey force-pushed the remove_entries branch 4 times, most recently from 4cef9a8 to 91d15e3 Compare October 9, 2023 19:50
@KoBeWi
Copy link
Member

KoBeWi commented Oct 9, 2023

Deleting all entries under a file should also delete the file:

godot.windows.editor.dev.x86_64_B39QGrj5Tf.mp4

Also deleting a file with many results seems to cause a short freeze and error spam 🤔

@Stronkkey
Copy link
Author

Stronkkey commented Oct 10, 2023

@KoBeWi Can't replicate this issue and also it's kind of expected when you are hiding files with a lot of matches (10k+).

Deleting all entries under a file should also delete the file:

I don't think this is possible with the current implementation of TreeItem and Tree.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 10, 2023

Can't replicate this issue and also it's kind of expected when you are hiding files with a lot of matches (10k+).

godot.windows.editor.dev.x86_64_9wnf582zyo.mp4

I deleted 39 out of 600 results. It's far from thousands.
The error spam might be the cuprit.

I don't think this is possible with the current implementation of TreeItem and Tree.

Why? When deleting item, check if it's the only item. If not, delete item. If true, delete parent instead.

@Stronkkey
Copy link
Author

I deleted 39 out of 600 results. It's far from thousands.

I think this has to do with some other piece of code that is causing all these errors because when I test it out, it works fine without any errors.

@KoBeWi
Copy link
Member

KoBeWi commented Oct 10, 2023

I'm testing on newest master, so maybe try rebasing if you are not up-to-date.

@Stronkkey
Copy link
Author

@KoBeWi Can't seem to be able to replicate it. Also can someone rerun the checks?

@KoBeWi
Copy link
Member

KoBeWi commented Oct 12, 2023

Your newest changes fixed the errors and lag, but deleting file does not update matches:

godot.windows.editor.dev.x86_64_Zz0R1HGs2y.mp4

@Stronkkey
Copy link
Author

@KoBeWi Should be fixed in the newest but I doubt this will get merged before 4.2

@AThousandShips
Copy link
Member

It's an enhancement and we're in feature freeze so it won't be merged until 4.3, no rush to fix anything but nothing stopping working on it either :)

Comment on lines +874 to +875
if (_result_items.find(p_item)) {
_result_items.erase(p_item);
Copy link
Member

@KoBeWi KoBeWi Oct 12, 2023

Choose a reason for hiding this comment

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

You can avoid double lookup if you do

Suggested change
if (_result_items.find(p_item)) {
_result_items.erase(p_item);
HashMap<TreeItem *, Result>::Iterator E = _result_items.find(p_item);
if (E) {
_result_items.remove(E);

EDIT:
Also this piece of code is repeated so many times that you could extract it to a method, e.g. _delete_result_item(item).

Copy link
Member

@KoBeWi KoBeWi left a comment

Choose a reason for hiding this comment

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

Left one minor comment, but otherwise it's fine.

@akien-mga akien-mga modified the milestones: 4.x, 4.3 Oct 13, 2023
_file_items.erase(file_path);
}

get_tree()->queue_delete(p_item);
Copy link
Member

Choose a reason for hiding this comment

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

I'd move this below as well just to ensure that we don't operate on something after we've queued the deletion, just for correctness and safety

Copy link
Member

@AThousandShips AThousandShips left a comment

Choose a reason for hiding this comment

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

LGTM otherwise

@akien-mga
Copy link
Member

@Stronkkey Are you available to address the last review comments?

@Stronkkey Stronkkey closed this Jan 9, 2024
@AThousandShips AThousandShips removed this from the 4.3 milestone Jan 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow removing files from Search Results
6 participants