diff --git a/autoload/leaderf/fileExpl.py b/autoload/leaderf/fileExpl.py index d980574a..9a8a3969 100644 --- a/autoload/leaderf/fileExpl.py +++ b/autoload/leaderf/fileExpl.py @@ -148,8 +148,13 @@ def _refresh(self): cacheFile.write(line + '\n') def getContent(self, *args, **kwargs): - dir = os.getcwd() if len(args) == 0 else args[0] - dir = os.path.abspath(dir) + if len(args) > 0: + if os.path.exists(args[0]): + os.chdir(args[0]) + else: + vim.command("echohl ErrorMsg | redraw | echon 'Unknown directory `%s`' | echohl NONE" % args[0]) + return None + dir = os.getcwd() if vim.eval("g:Lf_UseMemoryCache") == 0 or dir != self._curDir: self._curDir = dir self._content = self._getFileList(dir) diff --git a/autoload/leaderf/manager.py b/autoload/leaderf/manager.py index ac99864b..2a1e58a8 100644 --- a/autoload/leaderf/manager.py +++ b/autoload/leaderf/manager.py @@ -368,10 +368,6 @@ def accept(self, mode = ''): self._accept(file, mode) def quit(self): - if self._autochdir == 1: - cwd = os.getcwd() - vim.command("set autochdir") # I think vim has a bug here - os.chdir(cwd) self._cli.clear() self._selections.clear() if self._winPos != 0 and len(vim.windows) > 1: @@ -386,6 +382,10 @@ def quit(self): vim.command("call getchar(0) | redraw | echo") else: vim.command("call getchar(0)") + if self._autochdir == 1: + cwd = os.getcwd() + vim.command("set autochdir") # I think vim has a bug here + os.chdir(cwd) def refresh(self, content = None): rContent = self._getExplorer().getFreshContent() @@ -424,10 +424,12 @@ def addSelections(self): def startExplorer(self, *args, **kwargs): self._cli.setFullPathFeature(self._getExplorer().supportsFullPath()) - self._gotoBuffer() vim.command("let g:Lf_statusline_function = '%s'" % self._getExplorer().getStlFunction()) vim.command("echohl WarningMsg | redraw | echo ' searching ...' | echohl NONE") content = self._getExplorer().getContent(*args, **kwargs) + if content is None: + return + self._gotoBuffer() vim.command("let g:Lf_statusline_curDir = '%s'" % self._getExplorer().getStlCurDir()) self.startExplAction(content)