dhruvasagar / vim-prosession

Handle vim sessions like a pro
254 stars 22 forks source link

shellslash breaks session filename generation in Windows #37

Closed nkmathew closed 6 years ago

nkmathew commented 7 years ago

It's assuming that paths in Windows will always have backslashes:

function! s:undofile(cwd) "{{{1
  if has('win16') || has('win32') || has('win64')
    return substitute(a:cwd, '\', '%', 'g')
  else
    return substitute(a:cwd, '/', '%', 'g')
  endif
endfunction
dhruvasagar commented 7 years ago

Hi, that's right. I suppose I should use &shellslash value, although I am not entirely sure how wrong slashes behave on windows.

nkmathew commented 7 years ago

Or just replace both slashes with a regex, should work for most cases. It could probably fail for paths with spaces e.g. '/first/second/some\ folder' but if you're seriously doing that then you deserve to be bitten :)

Grueslayer commented 7 years ago

Both expand() and glob() will make the "right" slash from a mixed filename and escaped spaces and like dhruvasagar wrote, the shellslash option tells what kind of slash expand() and glob() is using.

:set nossl
:echo expand('c:\temp/new\ folder/sub')

c:\temp\new folder\sub
:set ssl
:echo expand('c:\temp/new\ folder/sub')

c:/temp/new folder/sub

P.S. getcwd() also works like this.

dhruvasagar commented 6 years ago

Closing this issue for now, reopen if you face any issues.