Repository: spyder-ide/spyder

Issue:
File switcher is changing size when changing from symbols to files
Easy way to reproduce this

1. Press the file switcher button in the file toolbar.
2. Press `Esc` to hide the file switcher.
3. Press the symbol finder button in the file toolbar.
4. Press again the file switcher button.

@dalthviz, besides fixing this error, we have to make sure to remove all text present in the switcher every time we're going to show it again.


Discussion:

Resolving patch:
diff --git a/spyder/app/mainwindow.py b/spyder/app/mainwindow.py
--- a/spyder/app/mainwindow.py
+++ b/spyder/app/mainwindow.py
@@ -2756,6 +2756,8 @@ def open_fileswitcher(self, symbol=False):
             return
         if symbol:
             self.fileswitcher.plugin = self.editor
+        else:
+            self.fileswitcher.set_search_text('')
         self.fileswitcher.setup()
         self.fileswitcher.show()
         self.fileswitcher.is_visible = True
@@ -2764,6 +2766,7 @@ def open_symbolfinder(self):
         """Open symbol list management dialog box."""
         self.open_fileswitcher(symbol=True)
         self.fileswitcher.set_search_text('@')
+        self.fileswitcher.setup()
 
     def add_to_fileswitcher(self, plugin, tabs, data, icon):
         """Add a plugin to the File Switcher."""
diff --git a/spyder/widgets/fileswitcher.py b/spyder/widgets/fileswitcher.py
--- a/spyder/widgets/fileswitcher.py
+++ b/spyder/widgets/fileswitcher.py
@@ -477,6 +477,9 @@ def select_row(self, steps):
 
     def previous_row(self):
         """Select previous row in list widget."""
+        if self.mode == self.SYMBOL_MODE:
+            self.select_row(-1)
+            return
         prev_row = self.current_row() - 1
         if prev_row == 0:
             self.list.scrollToTop()
@@ -488,6 +491,9 @@ def previous_row(self):
 
     def next_row(self):
         """Select next row in list widget."""
+        if self.mode == self.SYMBOL_MODE:
+            self.select_row(+1)
+            return
         next_row = self.current_row() + 1
         if next_row < self.count():
             if '</b></big><br>' in self.list.item(next_row).text():
@@ -652,7 +658,7 @@ def setup_file_list(self, filter_text, current_path):
             self.set_current_row(self.filtered_path.index(current_path))
         elif self.filtered_path:
             self.set_current_row(0)
-        self.fix_size(short_paths, extra=200)
+        self.fix_size(short_paths, extra=100)
 
         # If a line number is searched look for it
         self.line_number = line_number
@@ -667,6 +673,10 @@ def setup_symbol_list(self, filter_text, current_path):
         oedata = self.get_symbol_list()
         icons = get_python_symbol_icons(oedata)
 
+        # The list of shorten paths here is needed in order to have the same
+        # point of measurement for the list widget width as in the file list
+        # See issue 4648
+        short_paths = shorten_paths(self.paths, self.save_status)
         symbol_list = process_python_symbol_data(oedata)
         line_fold_token = [(item[0], item[2], item[3]) for item in symbol_list]
         choices = [item[1] for item in symbol_list]
@@ -709,7 +719,7 @@ def setup_symbol_list(self, filter_text, current_path):
         # self.set_current_row(0)
 
         # Update list size
-        self.fix_size(lines, extra=125)
+        self.fix_size(short_paths, extra=100)
 
     def setup(self):
         """Setup list widget content."""


Test patch: