File tree Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Expand file tree Collapse file tree 1 file changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -1056,13 +1056,24 @@ function! s:init_env()
1056
1056
\ ' PWD' : 1 ,
1057
1057
\ }
1058
1058
1059
- function ! s: get_env ()
1059
+ if exists (' *environ' )
1060
+ let env = items (environ ())
1061
+ else
1060
1062
redir = > s
1061
1063
silent ! execute " norm!:ec$\<c-a> '\<c-b>\<right>\<right>\<del> '\<cr> "
1062
1064
redir END
1063
1065
redraw
1064
- return split (s )
1065
- endfunction
1066
+ let env = map (split (s ), ' [v:val, eval("$".v:val)]' )
1067
+ endif
1068
+
1069
+ for [var , val] in env
1070
+ if has (' win32' ) ? (val[1 ] != ' :' ) : (val[0 ] != ' /' )
1071
+ \ || has_key (ignore , var )
1072
+ \ || len (var ) > len (val)
1073
+ continue
1074
+ endif
1075
+ call insert (s: env , [var , val], 0 )
1076
+ endfor
1066
1077
1067
1078
function ! s: compare_by_key_len (foo, bar )
1068
1079
return len (a: foo [0 ]) - len (a: bar [0 ])
@@ -1071,16 +1082,6 @@ function! s:init_env()
1071
1082
return len (a: bar [1 ]) - len (a: foo [1 ])
1072
1083
endfunction
1073
1084
1074
- for k in s: get_env ()
1075
- silent ! execute " let v = eval('$'.k)"
1076
- if has (' win32' ) ? (v [1 ] != ' :' ) : (v [0 ] != ' /' )
1077
- \ || has_key (ignore , k )
1078
- \ || len (k ) > len (v )
1079
- continue
1080
- endif
1081
- call insert (s: env , [k ,v ], 0 )
1082
- endfor
1083
-
1084
1085
let s: env = sort (s: env , ' s:compare_by_key_len' )
1085
1086
let s: env = sort (s: env , ' s:compare_by_val_len' )
1086
1087
endfunction
You can’t perform that action at this time.
0 commit comments