Skip to content

Commit 4a0c674

Browse files
committed
Support git select files with range to commit
1 parent 2479d9b commit 4a0c674

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

autoload/project/git.vim

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ function! s:SetupChangesBuffer(revision)
361361
syntax match Splitter "\$" conceal
362362
syntax match Splitter "!" conceal
363363
setlocal conceallevel=3
364-
setlocal concealcursor=nc
364+
setlocal concealcursor=nvc
365365

366366
setlocal buftype=nofile bufhidden=wipe nobuflisted
367367
setlocal nowrap
@@ -1259,6 +1259,7 @@ function! s:SetupChangelistBuffer()
12591259
call s:AddMapping(mappings.rename_changelist, '<SID>RenameFolder()')
12601260
call s:AddMapping(mappings.rollback_file, '<SID>RollbackFile()')
12611261
call s:AddMapping(mappings.commit, '<SID>Commit()')
1262+
call s:AddVisualMapping(mappings.commit, '<SID>Commit()')
12621263
call s:AddMapping(mappings.pull, '<SID>TryPull()')
12631264
call s:AddMapping(mappings.push, '<SID>TryPush()')
12641265
call s:AddMapping(mappings.pull_and_push, '<SID>TryPullThenPush()')
@@ -1276,7 +1277,7 @@ function! s:SetupChangelistBuffer()
12761277
syntax match Splitter "\$" conceal
12771278
syntax match Splitter "!" conceal
12781279
setlocal conceallevel=3
1279-
setlocal concealcursor=nc
1280+
setlocal concealcursor=nvc
12801281

12811282
setlocal buftype=nofile
12821283
setlocal nomodifiable
@@ -1321,7 +1322,7 @@ function! s:HighlightFiles(lines)
13211322
call project#HighlightIcon()
13221323
endfunction
13231324

1324-
function! s:Commit()
1325+
function! s:Commit() range
13251326
let files = []
13261327

13271328
let lnum = line('.')
@@ -1334,7 +1335,10 @@ function! s:Commit()
13341335
let folder = s:GetBelongFolder(lnum)
13351336
let files = folder.files
13361337
else
1337-
let files = [file]
1338+
let files = []
1339+
for lnum in range(a:firstline, a:lastline)
1340+
call add(files, s:GetFileByLine(lnum))
1341+
endfor
13381342
endif
13391343

13401344
let check_files = s:changed_files + s:untracked_files + s:staged_files + s:unmerged_files
@@ -1360,13 +1364,14 @@ function! s:GetCommitMessage()
13601364
let folder_name = !empty(folder) ? s:RemoveFolderNamePrefix(folder.name) : ''
13611365

13621366
let title = ''
1363-
let Message = project#GetVariable('commit_message')
1367+
let CustomMessage = project#GetVariable('commit_message')
1368+
13641369

1365-
if !empty(Message)
1366-
if type(Message) == type(function('tr'))
1367-
let title = Message(folder_name)
1368-
elseif type(Message) == type('')
1369-
let title = Message
1370+
if !empty(CustomMessage)
1371+
if type(CustomMessage) == type(function('tr'))
1372+
let title = CustomMessage(folder_name)
1373+
elseif type(CustomMessage) == type('')
1374+
let title = CustomMessage
13701375
endif
13711376
endif
13721377

0 commit comments

Comments
 (0)