- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 23.5k
 
          Support keeping results in results of Find in Files and Replacing in Files
          #104676
        
          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
base: master
Are you sure you want to change the base?
  
    Support keeping results in results of Find in Files and Replacing in Files
  
  #104676
              Conversation
| 
           I feel like all these 3 text buttons in future could be replaced with just 3 icons.  | 
    
96bb797    to
    aaaafd8      
    Compare
  
    84af7d4    to
    7e718a8      
    Compare
  
    7e718a8    to
    38888c1      
    Compare
  
            
          
                editor/find_in_files.cpp
              
                Outdated
          
        
      | 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"; | 
There was a problem hiding this comment.
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 *.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| void FindInFilesPanel::set_search_labels_visibility(bool p_visible) { | ||
| _find_label->set_visible(p_visible); | ||
| _search_text_label->set_visible(p_visible); | ||
| } | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
        
          
                editor/find_in_files.h
              
                Outdated
          
        
      | class TabContainer; | ||
| 
               | 
          ||
| // Contains several panels | ||
| class FindInFilesTab : public TabContainer { | 
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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. 
godot/editor/debugger/editor_debugger_node.cpp
Lines 68 to 75 in 51b0379
| 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.
There was a problem hiding this comment.
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.
        
          
                editor/find_in_files.cpp
              
                Outdated
          
        
      | 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 | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // 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. | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
        
          
                editor/find_in_files.h
              
                Outdated
          
        
      | class PopupMenu; | ||
| class TabContainer; | ||
| 
               | 
          ||
| // Contains several panels | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Contains several panels | |
| // Contains several panels. | 
Also would it be possible to make this more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. More details added.
64b3b16    to
    c0c5fd9      
    Compare
  
            
          
                editor/find_in_files.cpp
              
                Outdated
          
        
      | 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)); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 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
There was a problem hiding this comment.
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")?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
c0c5fd9    to
    c4178be      
    Compare
  
            
          
                editor/find_in_files.h
              
                Outdated
          
        
      | FindInFilesPanel *create_new_panel(); | ||
| FindInFilesPanel *get_curr_panel(); | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
        
          
                editor/find_in_files.h
              
                Outdated
          
        
      | Button *_replace_all_button = nullptr; | ||
| }; | ||
| 
               | 
          ||
| class MarginContainer; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| class MarginContainer; | 
You don't need to forward declare this class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
        
          
                editor/find_in_files.h
              
                Outdated
          
        
      | 
               | 
          ||
| void set_with_replace(bool with_replace); | ||
| void set_replace_text(const String &text); | ||
| bool keep_results() const; | 
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, fixed.
c4178be    to
    9685de0      
    Compare
  
    There was a problem hiding this 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):

        
          
                editor/find_in_files.h
              
                Outdated
          
        
      | FindInFilesPanel *create_new_panel(); | ||
| FindInFilesPanel *get_current_panel(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| FindInFilesPanel *create_new_panel(); | |
| FindInFilesPanel *get_current_panel(); | |
| FindInFilesPanel *_create_new_panel(); | |
| FindInFilesPanel *_get_current_panel(); | 
Private functions should have the "_" prefix
There was a problem hiding this comment.
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.
9685de0    to
    1c456bd      
    Compare
  
    05407d3    to
    53ddcb4      
    Compare
  
    53ddcb4    to
    1565d54      
    Compare
  
    e52e35d    to
    8793058      
    Compare
  
    8793058    to
    3f00759      
    Compare
  
    3f00759    to
    04dfd7a      
    Compare
  
    
Closes godotengine/godot-proposals#11923
Support keeping multiple searching/replacing results.