Skip to content

Commit e7a0e9f

Browse files
committed
Add %P format item
1 parent 992bb7b commit e7a0e9f

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

autoload/flog/floggraph/format.vim

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,24 @@ function! flog#floggraph#format#FormatMarkLocalBranch(dict, key) abort
127127
return flog#floggraph#format#FormatCommitLocalBranch(a:dict, l:commit)
128128
endfunction
129129

130-
function! flog#floggraph#format#FormatPath() abort
130+
function! flog#floggraph#format#FormatPath(separate_args) abort
131131
let l:state = flog#state#GetBufState()
132132
let l:path = l:state.opts.path
133133

134134
if !empty(l:state.opts.limit)
135135
let [l:range, l:limit_path] = flog#args#SplitGitLimitArg(l:state.opts.limit)
136136

137137
if empty(l:limit_path)
138-
return ''
138+
return a:separate_args ? '--' : ''
139139
endif
140140

141141
let l:path = [l:limit_path]
142142
elseif empty(l:path)
143-
return ''
143+
return a:separate_args ? '--' : ''
144144
endif
145145

146-
return join(flog#shell#EscapeList(l:path), ' ')
146+
let l:paths = join(flog#shell#EscapeList(l:path), ' ')
147+
return a:separate_args ? '-- ' .. l:paths : l:paths
147148
endfunction
148149

149150
function! flog#floggraph#format#FormatIndexTree(dict) abort
@@ -186,7 +187,9 @@ function! flog#floggraph#format#HandleCommandItem(dict, item, end) abort
186187
elseif a:item =~# "^%(l'."
187188
let l:formatted_item = flog#floggraph#format#FormatMarkLocalBranch(a:dict, a:item[4 : -2])
188189
elseif a:item ==# '%p'
189-
let l:formatted_item = flog#floggraph#format#FormatPath()
190+
let l:formatted_item = flog#floggraph#format#FormatPath(v:false)
191+
elseif a:item ==# '%P'
192+
let l:formatted_item = flog#floggraph#format#FormatPath(v:true)
190193
elseif a:item ==# '%t'
191194
let l:formatted_item = flog#floggraph#format#FormatIndexTree(a:dict)
192195
else

doc/flog.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,11 @@ The following items are supported:
12561256
|:Flog_-path|, if any, escaping them and joining them
12571257
with spaces.
12581258

1259+
*flog-%P*
1260+
%P Same as |flog-%p|, but include "--" at the start.
1261+
Separates Git command arguments from paths.
1262+
Still returns "--" if no path or limit is specified.
1263+
12591264
*flog-%t*
12601265
%t A tree for the current index. When this is used, a new
12611266
tree will be created for the current index using

0 commit comments

Comments
 (0)