Repository: spyder-ide/spyder

Issue:
Remember what was selected in the "Search in" combo box of the "Find"pluggin
I would like that on restart, Spyder remembers what was selected in the "Search in" combo box of the `Find` plugin.

If you agree with that, what do we need to do to achieve that? Do we simply add it to our config?

![image](https://user-images.githubusercontent.com/10170372/59511675-e2002b80-8e84-11e9-9683-29e83e896b0f.png)


## Versions

* Spyder 4.0.0.dev0 (Commit: f17a9b15c) 
* Python 3.7.1 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Windows 10 



Discussion:
This is a good idea, so I agree with it.

> Do we simply add it to our config?

Please take a look at how history is saved for the Working directory and follow the same pattern.

Resolving patch:
diff --git a/spyder/plugins/findinfiles/plugin.py b/spyder/plugins/findinfiles/plugin.py
--- a/spyder/plugins/findinfiles/plugin.py
+++ b/spyder/plugins/findinfiles/plugin.py
@@ -52,6 +52,7 @@ def __init__(self, parent=None):
         more_options = self.get_option('more_options')
         case_sensitive = self.get_option('case_sensitive')
         path_history = self.get_option('path_history', [])
+        search_in_index = self.get_option('search_in_index', default=0)
 
         self.findinfiles = FindInFilesWidget(
                                    self,
@@ -60,6 +61,7 @@ def __init__(self, parent=None):
                                    supported_encodings,
                                    more_options,
                                    case_sensitive, path_history,
+                                   search_in_index,
                                    options_button=self.options_button,
                                    text_color=ima.MAIN_FG_COLOR)
 
@@ -172,7 +174,7 @@ def closing_plugin(self, cancelable=False):
             (search_text, text_re,
              exclude, exclude_idx, exclude_re,
              more_options, case_sensitive,
-             path_history) = options
+             path_history, search_in_index) = options
             hist_limit = 15
             search_text = search_text[:hist_limit]
             exclude = exclude[:hist_limit]
@@ -185,6 +187,7 @@ def closing_plugin(self, cancelable=False):
             self.set_option('more_options', more_options)
             self.set_option('case_sensitive', case_sensitive)
             self.set_option('path_history', path_history)
+            self.set_option('search_in_index', search_in_index)
         return True
 
     def on_first_registration(self):
diff --git a/spyder/plugins/findinfiles/widgets.py b/spyder/plugins/findinfiles/widgets.py
--- a/spyder/plugins/findinfiles/widgets.py
+++ b/spyder/plugins/findinfiles/widgets.py
@@ -309,6 +309,12 @@ def get_current_searchpath(self):
         else:
             return self.external_path
 
+    def set_current_searchpath_index(self, index):
+        """Set the current index of this combo box."""
+        index = min(index, self.count() - 1)
+        index = CWD if index in [CLEAR_LIST, SELECT_OTHER] else index
+        self.setCurrentIndex(index)
+
     def is_file_search(self):
         """Returns whether the current search path is a file."""
         if self.currentIndex() == FILE_PATH:
@@ -409,7 +415,8 @@ class FindOptions(QWidget):
     def __init__(self, parent, search_text, search_text_regexp,
                  exclude, exclude_idx, exclude_regexp,
                  supported_encodings, more_options,
-                 case_sensitive, external_path_history, options_button=None):
+                 case_sensitive, external_path_history, search_in_index,
+                 options_button=None):
         QWidget.__init__(self, parent)
 
         if not isinstance(search_text, (list, tuple)):
@@ -485,6 +492,7 @@ def __init__(self, parent, search_text, search_text_regexp,
         search_on_label = QLabel(_("Search in:"))
         self.path_selection_combo = SearchInComboBox(
                 external_path_history, parent)
+        self.path_selection_combo.set_current_searchpath_index(search_in_index)
 
         hlayout3.addWidget(search_on_label)
         hlayout3.addWidget(self.path_selection_combo)
@@ -544,10 +552,12 @@ def get_options(self, to_save=False):
             exclude_idx = self.exclude_pattern.currentIndex()
             path_history = self.path_selection_combo.get_external_paths()
             more_options = self.more_options.isChecked()
+            search_in_index = self.path_selection_combo.currentIndex()
             return (search_text, text_re,
                     exclude, exclude_idx,
                     exclude_re, more_options,
-                    case_sensitive, path_history)
+                    case_sensitive, path_history,
+                    search_in_index)
 
         # Clear fields
         self.search_text.lineEdit().setStyleSheet("")
@@ -955,6 +965,7 @@ def __init__(self, parent,
                  more_options=True,
                  case_sensitive=False,
                  external_path_history=[],
+                 search_in_index=0,
                  options_button=None,
                  text_color=None):
         QWidget.__init__(self, parent)
@@ -973,6 +984,7 @@ def __init__(self, parent,
                                         more_options,
                                         case_sensitive,
                                         external_path_history,
+                                        search_in_index,
                                         options_button=options_button)
         self.find_options.find.connect(self.find)
         self.find_options.stop.connect(self.stop_and_reset_thread)


Test patch: