-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve compatibility with windows #21
base: master
Are you sure you want to change the base?
Conversation
@@ -15,7 +15,7 @@ endfunction | |||
|
|||
" fix for Windows users (https://github.com/wting/gitsessions.vim/issues/2) | |||
if !exists('g:VIMFILESDIR') | |||
let g:VIMFILESDIR = has('unix') ? $HOME . '/.vim/' : $VIM . '/vimfiles/' | |||
let g:VIMFILESDIR = has('unix') ? $HOME . '/.vim/' : $HOME . '/vimfiles/' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this a tautology and break the original reason why we added this line? Why bother with the unix check?
if has('unix') | ||
return a:path[0] == s:os_sep() | ||
else | ||
return a:path[1] == ':' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of hardcoding the path separator could we simply change the index position? Why use == ':'
?
return a:path[1] == ':' | |
return a:path[1] == s:os_sep() |
endfunction | ||
|
||
" LOGIC FUNCTIONS | ||
|
||
function! s:parent_dir(path) | ||
let l:sep = s:os_sep() | ||
let l:front = s:is_abs_path(a:path) ? l:sep : '' | ||
let l:front = s:is_abs_path(a:path) && has('unix') ? l:sep : '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the has('unix')
check make the is_abs_path(a:path)
changes unnecessary since it'll never be true on Windows?
The result is all absolute paths are converted into relative paths on Windows, regardless if it was an absolute path to begin with or not.
return a:dir . '/.git' | ||
elseif has('file_in_path') && has('path_extra') | ||
if isdirectory(a:dir . s:os_sep() . '.git') | ||
return a:dir . s:os_sep() . '.git' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching this! 👍
if has('unix') | ||
let l:path = a:sdir . a:pdir | ||
else | ||
let l:path = a:sdir . substitute(a:pdir,'^\([A-Z]\):','\\\1','g') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is some regex backreferencing stuff. Can you help me understand why this change is necessary?
I had to make some tweaks to have the plugin working on windows. I also tested it on linux and it seems that there are no regressions there.
Please tell me if some other change or explanation is required in order to merge.