Skip to content

Commit afdcb3b

Browse files
ccordoba12meeseeksmachine
authored andcommitted
Backport PR spyder-ide#23965: PR: Add option to disable searching files in the switcher (Projects)
1 parent 413fcdc commit afdcb3b

File tree

2 files changed

+44
-5
lines changed

2 files changed

+44
-5
lines changed

spyder/config/main.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@
328328
'show_hidden': True,
329329
'size_column': False,
330330
'type_column': False,
331-
'date_column': False
331+
'date_column': False,
332+
'search_files_in_switcher': True,
332333
}),
333334
('explorer',
334335
{

spyder/plugins/projects/widgets/main_widget.py

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
QHBoxLayout, QInputDialog, QLabel, QMessageBox, QVBoxLayout, QWidget)
2424

2525
# Local imports
26+
from spyder.api.config.decorators import on_conf_change
2627
from spyder.api.exceptions import SpyderAPIError
2728
from spyder.api.translations import _
2829
from spyder.api.widgets.main_widget import PluginMainWidget
@@ -76,6 +77,10 @@ class RecentProjectsMenuSections:
7677
Extras = 'extras_section'
7778

7879

80+
class ProjectsOptionsMenuActions:
81+
SearchInSwitcher = "search_in_switcher"
82+
83+
7984
# ---- Main widget
8085
# -----------------------------------------------------------------------------
8186
@class_register
@@ -269,16 +274,33 @@ def setup(self):
269274
self.recent_project_menu.aboutToShow.connect(self._setup_menu_actions)
270275
self._setup_menu_actions()
271276

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+
272288
# Add some DirView actions to the Options menu for easy access.
273-
menu = self.get_options_menu()
274289
hidden_action = self.get_action(DirViewActions.ToggleHiddenFiles)
275290
single_click_action = self.get_action(DirViewActions.ToggleSingleClick)
276291

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+
]:
278299
self.add_item_to_menu(
279300
action,
280301
menu=menu,
281-
section=ProjectExplorerOptionsMenuSections.Main)
302+
section=ProjectExplorerOptionsMenuSections.Main
303+
)
282304

283305
def set_pane_empty(self):
284306
self.treewidget.hide()
@@ -1034,7 +1056,11 @@ def _call_fzf(self, search_text=""):
10341056
The search text to pass to fzf.
10351057
"""
10361058
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+
):
10381064
return
10391065

10401066
self._worker_manager.terminate_all()
@@ -1133,6 +1159,18 @@ def _update_default_switcher_paths(self):
11331159
self._default_switcher_paths = []
11341160
self._call_fzf()
11351161

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+
11361174
# =============================================================================
11371175
# Tests
11381176
# =============================================================================

0 commit comments

Comments
 (0)