Skip to content

Commit

Permalink
fix issue #2 again
Browse files Browse the repository at this point in the history
LeaderF couldn't work if an directory parameter was supplied to the
LeaderF command.
  • Loading branch information
Yggdroot committed Apr 1, 2014
1 parent 7b899bf commit bd52666
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
9 changes: 7 additions & 2 deletions autoload/leaderf/fileExpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions autoload/leaderf/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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()
Expand Down Expand Up @@ -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)

Expand Down

1 comment on commit bd52666

@cherrot
Copy link

@cherrot cherrot commented on bd52666 Apr 2, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks indeed! I love this plugin! It's much faster than ctrlp :)

Please sign in to comment.