Skip to content

Loading…

Fix path styles #144

Closed
wants to merge 1 commit into from

2 participants

@char101
  • Fix short path style when autochdir isset
  • Fix full path style
@char101 char101 Fix path styles
- Fix short path style when autochdir isset
- Fix full path style
751bb94
@Lokaltog
Owner

What exactly does this change do?

@char101
  • for the 'short' style, if autochdir is set, it's useless to expand to the current dir, since it will always be expanded to the base filename only. So instead just take the head directory and shorten it to the initial letters

  • for the 'full' style, it simply doesn't work.

let filepath = expand('%') -> file.txt
let ret = filepath . dirsep -> file.txt/

which ends up being file.txt/file.txt in the status line.

The right way is

let filepath = expand('%:p') -> /some/dir/file.txt
let ret = fnamemodify(filepath, ':h') . dirsep -> /some/dir/

@Lokaltog
Owner

Looks good, thanks! I'll merge it soon.

@Lokaltog Lokaltog added a commit that closed this pull request
@char101 char101 Fix path styles
- Fix short path style when autochdir isset
- Fix full path style

Closes #144.
fa55b81
@Lokaltog Lokaltog closed this in fa55b81
@neersighted neersighted added a commit that referenced this pull request
@char101 char101 Fix path styles
- Fix short path style when autochdir isset
- Fix full path style

Closes #144.
c0cdd62
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 21, 2012
  1. @char101

    Fix path styles

    char101 committed
    - Fix short path style when autochdir isset
    - Fix full path style
This page is out of date. Refresh to see the latest.
Showing with 5 additions and 4 deletions.
  1. +5 −4 autoload/Powerline/Functions.vim
View
9 autoload/Powerline/Functions.vim
@@ -7,7 +7,7 @@ function! Powerline#Functions#GetFilepath() " {{{
endif
let dirsep = has('win32') && ! &shellslash ? '\' : '/'
- let filepath = expand('%')
+ let filepath = expand('%:p')
if empty(filepath)
return ''
@@ -23,7 +23,8 @@ function! Powerline#Functions#GetFilepath() " {{{
"
" This displays the shortest possible path, relative to ~ or the
" current directory.
- let fpath = split(fnamemodify(filepath, ':~:.:h'), dirsep)
+ let mod = (exists('+acd') && &acd) ? ':~:h' : ':~:.:h'
+ let fpath = split(fnamemodify(filepath, mod), dirsep)
let fpath_shortparts = map(fpath[1:], 'v:val[0]')
let ret = join(extend([fpath[0]], fpath_shortparts), dirsep) . dirsep
elseif g:Powerline_stl_path_style == 'relative'
@@ -31,10 +32,10 @@ function! Powerline#Functions#GetFilepath() " {{{
let ret = fnamemodify(filepath, ':.:h') . dirsep
elseif g:Powerline_stl_path_style == 'full'
" Display the full path, similar to the %F statusline item
- let ret = filepath . dirsep
+ let ret = fnamemodify(filepath, ':h') . dirsep
endif
- if ret == ('.'. dirsep)
+ if ret == ('.' . dirsep)
return ''
endif
Something went wrong with that request. Please try again.