about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2018-03-31 16:01:59 +0200
committertoonn <toonn@toonn.io>2018-03-31 17:32:04 +0200
commit2288a40b45ccdc57d287648c96c5bbe378b95a6d (patch)
treeb1afd734af047de10a5a2dbf306528e265ae3dde
parentf3d8c57b1fa24f0fa8b4c3d2e5f96bf6a2f9778e (diff)
downloadranger-2288a40b45ccdc57d287648c96c5bbe378b95a6d.tar.gz
ranger <path> can select files
Because `ranger somefile` used to invoke rifle but that moved to its own
command `ranger somefile` seemed defunct. People expected ranger to
select the file and were baffled when it crashed. Now the documentation
using the verbiage "path" is no longer confusing/a lie because it just
works™ (until it breaks).

Fixes #930
-rw-r--r--ranger/core/tab.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/ranger/core/tab.py b/ranger/core/tab.py
index 1d5e69d4..7bb45d75 100644
--- a/ranger/core/tab.py
+++ b/ranger/core/tab.py
@@ -4,7 +4,7 @@
 from __future__ import (absolute_import, division, print_function)
 
 import os
-from os.path import abspath, normpath, join, expanduser, isdir
+from os.path import abspath, normpath, join, expanduser, isdir, dirname
 import sys
 
 from ranger.container import settings
@@ -123,9 +123,11 @@ class Tab(FileManagerAware, SettingsAware):  # pylint: disable=too-many-instance
 
         # get the absolute path
         path = normpath(join(self.path, expanduser(path)))
+        selectfile = None
 
         if not isdir(path):
-            return False
+            selectfile = path
+            path = dirname(path)
         new_thisdir = self.fm.get_directory(path)
 
         try:
@@ -155,6 +157,8 @@ class Tab(FileManagerAware, SettingsAware):  # pylint: disable=too-many-instance
         self.thisdir.sort_directories_first = self.fm.settings.sort_directories_first
         self.thisdir.sort_reverse = self.fm.settings.sort_reverse
         self.thisdir.sort_if_outdated()
+        if selectfile:
+            self.thisdir.move_to_obj(selectfile)
         if previous and previous.path != path:
             self.thisfile = self.thisdir.pointed_obj
         else: