|
23 | 23 | QHBoxLayout, QInputDialog, QLabel, QMessageBox, QVBoxLayout, QWidget)
|
24 | 24 |
|
25 | 25 | # Local imports
|
| 26 | +from spyder.api.config.decorators import on_conf_change |
26 | 27 | from spyder.api.exceptions import SpyderAPIError
|
27 | 28 | from spyder.api.translations import _
|
28 | 29 | from spyder.api.widgets.main_widget import PluginMainWidget
|
@@ -76,6 +77,10 @@ class RecentProjectsMenuSections:
|
76 | 77 | Extras = 'extras_section'
|
77 | 78 |
|
78 | 79 |
|
| 80 | +class ProjectsOptionsMenuActions: |
| 81 | + SearchInSwitcher = "search_in_switcher" |
| 82 | + |
| 83 | + |
79 | 84 | # ---- Main widget
|
80 | 85 | # -----------------------------------------------------------------------------
|
81 | 86 | @class_register
|
@@ -269,16 +274,33 @@ def setup(self):
|
269 | 274 | self.recent_project_menu.aboutToShow.connect(self._setup_menu_actions)
|
270 | 275 | self._setup_menu_actions()
|
271 | 276 |
|
| 277 | + # We need to give users a way to disable searching files in the |
| 278 | + # switcher because in some situations it introduces delays in the |
| 279 | + # switcher or Spyder itself. |
| 280 | + # Fixes spyder-ide/spyder#22641 |
| 281 | + search_in_switcher_action = self.create_action( |
| 282 | + ProjectsOptionsMenuActions.SearchInSwitcher, |
| 283 | + text=_("Search files in the switcher"), |
| 284 | + toggled=True, |
| 285 | + option='search_files_in_switcher', |
| 286 | + ) |
| 287 | + |
272 | 288 | # Add some DirView actions to the Options menu for easy access.
|
273 |
| - menu = self.get_options_menu() |
274 | 289 | hidden_action = self.get_action(DirViewActions.ToggleHiddenFiles)
|
275 | 290 | single_click_action = self.get_action(DirViewActions.ToggleSingleClick)
|
276 | 291 |
|
277 |
| - for action in [hidden_action, single_click_action]: |
| 292 | + # Options menu |
| 293 | + menu = self.get_options_menu() |
| 294 | + for action in [ |
| 295 | + hidden_action, |
| 296 | + single_click_action, |
| 297 | + search_in_switcher_action, |
| 298 | + ]: |
278 | 299 | self.add_item_to_menu(
|
279 | 300 | action,
|
280 | 301 | menu=menu,
|
281 |
| - section=ProjectExplorerOptionsMenuSections.Main) |
| 302 | + section=ProjectExplorerOptionsMenuSections.Main |
| 303 | + ) |
282 | 304 |
|
283 | 305 | def set_pane_empty(self):
|
284 | 306 | self.treewidget.hide()
|
@@ -1034,7 +1056,11 @@ def _call_fzf(self, search_text=""):
|
1034 | 1056 | The search text to pass to fzf.
|
1035 | 1057 | """
|
1036 | 1058 | project_path = self.get_active_project_path()
|
1037 |
| - if self._fzf is None or project_path is None: |
| 1059 | + if ( |
| 1060 | + not self.get_conf("search_files_in_switcher") |
| 1061 | + or self._fzf is None |
| 1062 | + or project_path is None |
| 1063 | + ): |
1038 | 1064 | return
|
1039 | 1065 |
|
1040 | 1066 | self._worker_manager.terminate_all()
|
@@ -1133,6 +1159,18 @@ def _update_default_switcher_paths(self):
|
1133 | 1159 | self._default_switcher_paths = []
|
1134 | 1160 | self._call_fzf()
|
1135 | 1161 |
|
| 1162 | + @on_conf_change(option="search_files_in_switcher") |
| 1163 | + def _on_search_files_in_switcher_changed(self, value): |
| 1164 | + """ |
| 1165 | + Actions to take when users enable/disable searching files in the |
| 1166 | + switcher. |
| 1167 | + """ |
| 1168 | + if value: |
| 1169 | + self._update_default_switcher_paths() |
| 1170 | + else: |
| 1171 | + self._clear_switcher_paths() |
| 1172 | + |
| 1173 | + |
1136 | 1174 | # =============================================================================
|
1137 | 1175 | # Tests
|
1138 | 1176 | # =============================================================================
|
|
0 commit comments