thaerkh / vim-workspace

📑 Automated Vim session management with file auto-save and persistent undo history
Apache License 2.0
466 stars 30 forks source link

Fail to create session storage directory on MS Windows (bugfix provided) #30

Open iiifr opened 5 years ago

iiifr commented 5 years ago

I set my own g:workspace_session_directory in _vimrc , when vim-workspace creates a new session, it fail to create the session storage folder whose name contains opened project path. I looked into code of vim-workspace and figured out this problem is caused by not replacing character : and \ properly in Windows-style path. I modified the function GetSessionDirectoryPath() in plugin/workspace.vim and it's worked.
Modified GetSessionDirectoryPath():

function! s:GetSessionDirectoryPath()
  if !isdirectory(g:workspace_session_directory)
    call mkdir(g:workspace_session_directory)
  endif
  let l:cwd = getcwd()
  if has('win32')
    let l:fileName = substitute(l:cwd, '\', '%', 'g')
    let l:fileName = substitute(l:fileName, ':', '%', 'g')
  else
    let l:fileName = substitute(l:cwd, '/', '%', 'g')
  endif
  let l:fullPath = g:workspace_session_directory . l:fileName
  return l:fullPath
endfunction