Skip to content

Commit

Permalink
Switcher: Remove direct dependency on Projects
Browse files Browse the repository at this point in the history
That created a special case for Projects, which is not really necessary.
  • Loading branch information
ccordoba12 committed Aug 25, 2023
1 parent 5480966 commit e6140b1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 16 deletions.
3 changes: 2 additions & 1 deletion spyder/plugins/projects/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,8 @@ def _display_items_in_switcher(self, items, setup, clear_section):
section=section,
data=path,
last_item=is_last_item,
score=1e10 # To make the editor results appear first
score=1e10, # To make the editor results appear first
use_score=False # Results come from fzf in the right order
)

if setup:
Expand Down
11 changes: 1 addition & 10 deletions spyder/plugins/switcher/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class Switcher(SpyderPluginV2):
"""

NAME = "switcher"
OPTIONAL = [Plugins.MainMenu, Plugins.Projects]
OPTIONAL = [Plugins.MainMenu]
CONTAINER_CLASS = SwitcherContainer
CONF_SECTION = NAME
CONF_FILE = False
Expand Down Expand Up @@ -160,15 +160,6 @@ def on_main_menu_teardown(self):
menu_id=ApplicationMenus.File
)

@on_plugin_available(plugin=Plugins.Projects)
def on_projects_available(self):
projects = self.get_plugin(Plugins.Projects)
self._switcher.projects_section = projects.get_widget().get_title()

@on_plugin_teardown(plugin=Plugins.Projects)
def on_projects_teardown(self):
self._switcher.projects_section = None

# ---- Public API
# -------------------------------------------------------------------------
# Switcher methods
Expand Down
6 changes: 1 addition & 5 deletions spyder/plugins/switcher/widgets/switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ def __init__(self, parent, help_text=None, item_styles=ITEM_STYLES,
self._mode_on = ''
self._item_styles = item_styles
self._item_separator_styles = item_separator_styles
self.projects_section = None

# Widgets
self.edit = QLineEdit(self)
Expand Down Expand Up @@ -350,10 +349,7 @@ def setup(self):
rich_title = rich_title.replace(" ", " ")
item.set_rich_title(rich_title)

# Results come from Projects in the right order, so we don't need
# to sort them here.
if item._section != self.projects_section:
item.set_score(score_value)
item.set_score(score_value)

self.proxy.set_filter_by_score(True)
self.proxy.sortBy('_score')
Expand Down

0 comments on commit e6140b1

Please sign in to comment.