Compare commits

...

3 Commits

Author SHA1 Message Date
Peter Vandenberk
488c0555e4 Update README.mkd: offno for signcolumn
The valid values for `signcolumn` are '`auto`' ,'`no`', '`yes'` and '`number'` but not '`off'`:

```
E474: Invalid argument: signcolumn=off
```

Thanks!
2025-08-29 11:45:59 +01:00
Fred Hornsey
85ca3a0872 Use shellescape on paths in run_diff
In Neovim 0.11.1 within MSYS2 on Windows, gitgutter wasn't showing up.
After some flailing around, I found adding
`set shellcmdflag=-c shellxquote= shellxescape=`
[from here](https://github.com/neovim/neovim/issues/28384#issuecomment-2135921829),
got `:echo system('git --version')` working. The signs were still not
showing up, but there were files being dumped in my current working
directory that looked like corrupted Windows paths.

After using `let g:gitgutter_log=1` and looking at the log I found where
these temp files were made and I think I fixed it. I haven't tried the
non-msys2 Neovim (assuming that's different) or normal vim, but I
brought the change over and made sure it worked in Neovim on Linux.
2025-05-26 14:33:03 +01:00
Andy Stewart
a5ae0a5a18 Handle quickfix autocmd changing buffer
To keep things fast we turn off gitgutter in the current buffer during
quickfix commands, e.g. :vimgrep, and turn it back on afterwards.

However the user may have a quickfix autocmd which makes a different
buffer the current one, e.g. :cwindow. Previously this caused an error
because gitgutter expected the current buffer to remain current; now we
explicitly enable the original current buffer.

Fixes #904.
2025-05-05 15:15:44 +01:00
3 changed files with 17 additions and 5 deletions

View File

@@ -81,7 +81,7 @@ Second, ensure your `updatetime` and `signcolumn` options are set appropriately.
When you make a change to a file tracked by git, the diff markers should appear automatically after a short delay. The delay is governed by vim's `updatetime` option; the default value is `4000`, i.e. 4 seconds, but I suggest reducing it to around 100ms (add `set updatetime=100` to your vimrc). Note `updatetime` also controls the delay before vim writes its swap file (see `:help updatetime`).
The `signcolumn` option can have any value except `'off'`.
The `signcolumn` option can have any value except `'no'`.
### Windows

View File

@@ -116,7 +116,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
" Write file from index to temporary file.
let index_name = gitgutter#utility#get_diff_base(a:bufnr).':'.gitgutter#utility#base_path(a:bufnr)
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name.' > '.from_file.' || exit 0) && ('
let cmd .= gitgutter#git(a:bufnr).' --no-pager show --textconv '.index_name
let cmd .= ' > '.gitgutter#utility#shellescape(from_file).' || exit 0) && ('
elseif a:from ==# 'working_tree'
let from_file = gitgutter#utility#repo_path(a:bufnr, 1)
@@ -129,7 +130,8 @@ function! gitgutter#diff#run_diff(bufnr, from, preserve_full_diff) abort
let cmd .= ' -c "diff.noprefix=false"'
let cmd .= ' -c "core.safecrlf=false"'
endif
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args.' -- '.from_file.' '.buff_file
let cmd .= ' diff --no-ext-diff --no-color -U0 '.g:gitgutter_diff_args
let cmd .= ' -- '.gitgutter#utility#shellescape(from_file).' '.gitgutter#utility#shellescape(buff_file)
" Pipe git-diff output into grep.
if !a:preserve_full_diff && !empty(g:gitgutter_grep)

View File

@@ -341,8 +341,18 @@ augroup gitgutter
autocmd BufFilePre * call s:on_buffilepre(expand('<abuf>'))
autocmd BufFilePost * call s:on_buffilepost(expand('<abuf>'))
autocmd QuickFixCmdPre *vimgrep* let b:gitgutter_was_enabled = gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') | GitGutterBufferDisable
autocmd QuickFixCmdPost *vimgrep* if b:gitgutter_was_enabled | GitGutterBufferEnable | endif | unlet b:gitgutter_was_enabled
autocmd QuickFixCmdPre *vimgrep*
\ if gitgutter#utility#getbufvar(expand('<abuf>'), 'enabled') |
\ let s:gitgutter_was_enabled = expand('<abuf>') |
\ else |
\ let s:gitgutter_was_enabled = 0 |
\ endif |
\ GitGutterBufferDisable
autocmd QuickFixCmdPost *vimgrep*
\ if s:gitgutter_was_enabled |
\ call gitgutter#buffer_enable(s:gitgutter_was_enabled) |
\ endif |
\ unlet s:gitgutter_was_enabled
augroup END
" }}}