Skip to content

Conversation

@jinyangcruise
Copy link

Closes godotengine/godot-proposals#11923

Support keeping multiple searching/replacing results.

before after
屏幕截图 2025-03-27 095822 屏幕截图 2025-03-27 100026

@jinyangcruise jinyangcruise requested a review from a team as a code owner March 27, 2025 02:09
@arkology
Copy link
Contributor

arkology commented Mar 27, 2025

I feel like all these 3 text buttons in future could be replaced with just 3 icons.
Lock/refresh/close is really common and easy recognizable actions to represent as icons.

@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch 2 times, most recently from 96bb797 to aaaafd8 Compare March 27, 2025 08:37
@AThousandShips AThousandShips added this to the 4.x milestone Mar 27, 2025
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch 2 times, most recently from 84af7d4 to 7e718a8 Compare March 28, 2025 05:40
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from 7e718a8 to 38888c1 Compare June 11, 2025 07:25
Comment on lines 1198 to 1200
const char *FindInFilesTab::SIGNAL_RESULT_SELECTED = "result_selected";
const char *FindInFilesTab::SIGNAL_FILES_MODIFIED = "files_modified";
const char *FindInFilesTab::SIGNAL_CLOSE_BUTTON_CLICKED = "close_button_clicked";
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think its best to store the signal names as constants, this is not something I've seen anywhere else in the codebase. However, if you do end up keeping these, they should be StringName instead of char *.

Copy link
Author

Choose a reason for hiding this comment

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

I basically imitated the defining way of signal names in class FindInFiles, class FindInFilesDialog, class FindInFilesPanel in the way of writing. You can check find_in_files.h. Indeed I don't know why they wrote it that way. I can modify it as you said. Do you think I should also modify those lines in class FindInFiles, class FindInFilesDialog and class FindInFilesPanel?

Copy link
Contributor

Choose a reason for hiding this comment

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

This entire file seems inconsistent with the rest of the editor, even the ordering of the private, protected, public is different from what I've seen in other places

Copy link
Author

Choose a reason for hiding this comment

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

Well, I think it's better that I only modify the codes that I wrote😅Other modifications can be put on a separate pull request.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

Comment on lines 810 to 823
void FindInFilesPanel::set_search_labels_visibility(bool p_visible) {
_find_label->set_visible(p_visible);
_search_text_label->set_visible(p_visible);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

The Close button is also redundant in the TabContainer view, consider also hiding that.

Copy link
Author

Choose a reason for hiding this comment

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

done

class TabContainer;

// Contains several panels
class FindInFilesTab : public TabContainer {
Copy link
Contributor

@lodetrick lodetrick Jun 11, 2025

Choose a reason for hiding this comment

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

There is an extra margin around the TabContainer (even when the tabs are hidden), look at editor_debugger_node for how they solved this same issue. Essentially make this class inherit from MarginContainer and set your margins to negative the panel's margins. Although this will probably need a change in EditorBottomPanel. I've solved this problem in a separate PR that won't be merged for a while, so I'll create a small bugfix PR that fixes this specifically in an easier to review form.

Edit: Included in #107395

Copy link
Author

Choose a reason for hiding this comment

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

So I don't need to take care of this part, right?

Copy link
Contributor

@lodetrick lodetrick Jun 11, 2025

Choose a reason for hiding this comment

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

The PR that I've linked fixed a bug in the TabContainer theming where the corner radius is too large. You would still need to do the same fix that the EditorDebuggerNode does, but using the BottomPanel stylebox instead of the BottomPanelDebuggerOverride stylebox.

add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT));
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT));
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM));
tabs = memnew(TabContainer);
tabs->set_tabs_visible(false);
tabs->connect("tab_changed", callable_mp(this, &EditorDebuggerNode::_debugger_changed));
add_child(tabs);

Above is an excerpt that should give you an idea of what I'm saying. Just so you're aware, what I'm referring to as the margin is the empty space above, below, and to the side of the TabContainer. This is especially visible on the top as the space above the tabs but is equally there on the sides and bottom.

Copy link
Author

Choose a reason for hiding this comment

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

Thx, I fixed this part.

bool bar_visible = get_tab_count() > 1;
set_tabs_visible(bar_visible);

// Panel's some labels' texts are duplicate with tab's title, so we want to change their visibility depends on the bar's visibility
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Panel's some labels' texts are duplicate with tab's title, so we want to change their visibility depends on the bar's visibility
// Panel's some labels' texts are duplicate with tab's title, so we want to change their visibility depends on the bar's visibility.

Copy link
Author

Choose a reason for hiding this comment

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

done

class PopupMenu;
class TabContainer;

// Contains several panels
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Contains several panels
// Contains several panels.

Also would it be possible to make this more specific?

Copy link
Author

Choose a reason for hiding this comment

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

Done. More details added.

Comment on lines 1202 to 1204
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT));
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT));
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM));
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT));
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT));
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanelDebuggerOverride"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM));
add_theme_constant_override("margin_top", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))->get_margin(SIDE_TOP));
add_theme_constant_override("margin_left", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))->get_margin(SIDE_LEFT));
add_theme_constant_override("margin_right", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))->get_margin(SIDE_RIGHT));
add_theme_constant_override("margin_bottom", -EditorNode::get_singleton()->get_editor_theme()->get_stylebox(SNAME("BottomPanel"), EditorStringName(EditorStyles))->get_margin(SIDE_BOTTOM));

This also needs to be added to NOTIFICATION_THEME_CHANGED so when the theme changes, the margins are able to update

Copy link
Author

Choose a reason for hiding this comment

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

Yes. BTW, SNAME("BottomPanelDebuggerOverride") should be changed to SNAME("BottomPanel")?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, because this dock does not have the BottomPanelDebuggerOverride stylebox as its background, instead it uses BottomPanel as its stylebox, and so uses its margins.

Copy link
Author

Choose a reason for hiding this comment

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

Done.

@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from c0c5fd9 to c4178be Compare June 12, 2025 03:29
@jinyangcruise jinyangcruise requested a review from lodetrick June 12, 2025 05:28
Comment on lines 275 to 276
FindInFilesPanel *create_new_panel();
FindInFilesPanel *get_curr_panel();
Copy link
Contributor

Choose a reason for hiding this comment

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

These two can be made private, and you don't need to abbreviate current to curr, it only hurts readability.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, fixed.

Button *_replace_all_button = nullptr;
};

class MarginContainer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
class MarginContainer;

You don't need to forward declare this class

Copy link
Author

Choose a reason for hiding this comment

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

Removed.


void set_with_replace(bool with_replace);
void set_replace_text(const String &text);
bool keep_results() const;
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe make the function name more descriptive like will_keep_results or is_keeping_results, to make it clear that it is a getter function.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, fixed.

@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from c4178be to 9685de0 Compare June 12, 2025 08:06
Copy link
Contributor

@lodetrick lodetrick left a comment

Choose a reason for hiding this comment

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

Beyond some small things, it looks good! A note for future reviewers, the artifact in the top right is fixed in a separate PR (#107395):
Screenshot 2025-06-12 at 1 19 11 AM

Comment on lines 263 to 264
FindInFilesPanel *create_new_panel();
FindInFilesPanel *get_current_panel();
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
FindInFilesPanel *create_new_panel();
FindInFilesPanel *get_current_panel();
FindInFilesPanel *_create_new_panel();
FindInFilesPanel *_get_current_panel();

Private functions should have the "_" prefix

Copy link
Author

Choose a reason for hiding this comment

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

Thanks, I also fixed private variable tabs to _tabs. Appreciate your earnestness.

@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from 9685de0 to 1c456bd Compare June 12, 2025 08:31
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch 2 times, most recently from 05407d3 to 53ddcb4 Compare June 24, 2025 06:39
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from 53ddcb4 to 1565d54 Compare July 18, 2025 03:47
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch 2 times, most recently from e52e35d to 8793058 Compare September 19, 2025 10:43
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from 8793058 to 3f00759 Compare October 31, 2025 03:58
@jinyangcruise jinyangcruise force-pushed the find_in_files_keep_results branch from 3f00759 to 04dfd7a Compare November 3, 2025 03:14
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.

Support Keep Results in results of Find in Folder

4 participants