Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix GetShortPath() error on Windows

Closes #202.
  • Loading branch information...
commit 2af074850fde676743f655775e3e151925751adf 1 parent 6dc1b15
@mattn mattn authored committed
Showing with 1 addition and 1 deletion.
  1. +1 −1  autoload/Powerline/Functions.vim
View
2  autoload/Powerline/Functions.vim
@@ -50,7 +50,7 @@ function! Powerline#Functions#GetFilepath() " {{{
return ret
endfunction " }}}
function! Powerline#Functions#GetShortPath(threshold) " {{{
- let fullpath = split(substitute(expand('%:p:h'), $HOME, '~', 'g'), '/')
+ let fullpath = split(expand('%:~'), '[/\\]')
if len(fullpath) > a:threshold
let fullpath = [fullpath[0], '…'] + fullpath[-a:threshold + 1 :]

5 comments on commit 2af0748

@oracal

I think the :h argument to expand may have been lost here, I get the buffer name appended in the nerdtree status bar, which happens to be NERD_tree_1, which isn't particularly useful. If we wanted a nerdtree name in the status bar we could put it in as static text. Adding the :h fixes it on linux, I don't have access to windows though.

@ZyX-I

You can use fnamemodify('.', ':p')[-1:] to get current path separator (behavior is documented) (won’t work if current directory does not exists, though I am unsure how you can launch vim from unexisting directory). It is better then using [/\\]. Something like this:

let s:pathsepreg = '\V'.escape(fnamemodify('.', ':p')[-1:], '\')
function! Powerline#Functions#GetShortPath(threshold) " {{{
    let fullpath = split(expand('%:~'), s:pathsepreg)
@baopham

@ZyX-I actually that doesn't fix it for Mac (I did clear the cache too). Can we have a fix that works for all Linux, Mac and Windows?

@ZyX-I

@baopham Fix what? I just said that one should not use [/\\] as a regex for path separator.

@baopham

@ZyX-I, oops I misunderstood you, sorry. I meant a fix for the issue oracal mentioned above that the nerdtree buffer name gets appended in the status bar. The :h fixes this, so I was just hoping we could get it pushed to the official code.

Please sign in to comment.
Something went wrong with that request. Please try again.