Skip to content

Commit

Permalink
Do not jump if the file name is invalid.
Browse files Browse the repository at this point in the history
Fixes #16

Signed-off-by: Gregory L. Dietsche <[email protected]>
  • Loading branch information
farmergreg committed Jun 13, 2017
1 parent 104ca72 commit 9ee7fe2
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions plugin/vim-lastplace.vim
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ if !exists('g:lastplace_ignore_buftype')
endif

fu! s:lastplace()
"if the file does not exist on disk (a new, unsaved file) then do nothing
if empty(glob(@%))
return
endif

if index(split(g:lastplace_ignore_buftype, ","), &buftype) != -1
return
endif
Expand All @@ -40,6 +35,15 @@ fu! s:lastplace()
return
endif

try
"if the file does not exist on disk (a new, unsaved file) then do nothing
if empty(glob(@%))

This comment has been minimized.

Copy link
@shym

shym Jun 14, 2017

I’m surprised by this test (or the mismatch with the comment): if I have a file named a in a directory and that I create a file named ? or *, the test will be false even if this is a new unsaved file.
empty(filereadable(@%)) would be better (if the file exists but is not readable, we might just as well stop right there), wouldn’t it?

This comment has been minimized.

Copy link
@farmergreg

farmergreg Jun 14, 2017

Author Owner

Thanks for your feedback, but it will work correctly. For example, try this: touch a;vim \?

return
endif
catch
return
endtry

if line("'\"") > 0 && line("'\"") <= line("$")
"if the last edit position is set and is less than the
"number of lines in this buffer.
Expand Down

0 comments on commit 9ee7fe2

Please sign in to comment.