diff options
-rw-r--r-- | ranger/core/actions.py | 7 | ||||
-rw-r--r-- | ranger/gui/widgets/console.py | 6 |
2 files changed, 8 insertions, 5 deletions
diff --git a/ranger/core/actions.py b/ranger/core/actions.py index 5b18fae4..115faaa0 100644 --- a/ranger/core/actions.py +++ b/ranger/core/actions.py @@ -14,6 +14,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import os +import re import shutil from os.path import join, isdir from os import symlink, getcwd @@ -275,6 +276,12 @@ class Actions(FileManagerAware, EnvironmentAware, SettingsAware): # -- Searching # -------------------------- + def search_file(self, text, regexp=True): + if isinstance(text, str) and regexp: + text = re.compile(text, re.L | re.U | re.I) + self.env.last_search = text + self.search(order='search') + def search(self, order=None, forward=True): original_order = order if self.search_forward: diff --git a/ranger/gui/widgets/console.py b/ranger/gui/widgets/console.py index c18e7f50..0aa1f147 100644 --- a/ranger/gui/widgets/console.py +++ b/ranger/gui/widgets/console.py @@ -391,11 +391,7 @@ class SearchConsole(Console): self.history = self.histories[SEARCH_HISTORY] def execute(self): - if self.fm.env.cwd: - regexp = re.compile(self.line, re.L | re.U | re.I) - self.fm.env.last_search = regexp - if self.fm.search(order='search'): - self.fm.env.cf = self.fm.env.cwd.pointed_obj + self.fm.search_file(self.line, regexp=True) self.close() |