# HG changeset patch # User Ludovic Chabant # Date 1398051001 25200 # Node ID ac2c226f1bac65636ba0c9703a7b1b395fbb098a # Parent a383a816d9759df14a8b964baaa5c321f18c69f1# Parent b82babe7fdf83a9fff61b0497f38abf10b5a4a3c Merge pull request #1 from shaneharper/fix_blank_line_appended_to_hg_output Fix: remove blank line added by HgRepo.ReadCommandOutput(). diff -r a383a816d975 -r ac2c226f1bac plugin/lawrencium.vim --- a/plugin/lawrencium.vim Fri Mar 07 00:42:06 2014 -0800 +++ b/plugin/lawrencium.vim Sun Apr 20 20:30:01 2014 -0700 @@ -345,13 +345,22 @@ return system(l:hg_command) endfunction -" Runs a Mercurial command in the repo and read it output into the current +" Runs a Mercurial command in the repo and reads its output into the current " buffer. function! s:HgRepo.ReadCommandOutput(command, ...) abort + function! s:PutOutputIntoBuffer(command_line) + let l:was_buffer_empty = (line('$') == 1 && getline(1) == '') + execute '0read!' . escape(a:command_line, '%#\') + if l:was_buffer_empty " (Always true?) + " '0read' inserts before the cursor, leaving a blank line which needs to be deleted: + normal! Gdd + endif + endfunction + let l:all_args = [a:command] + a:000 let l:hg_command = call(self['GetCommand'], l:all_args, self) call s:trace("Running Mercurial command: " . l:hg_command) - execute '0read !' . escape(l:hg_command, '%#\') + call s:PutOutputIntoBuffer(l:hg_command) endfunction " Build a Lawrencium path for the given file and action.