Commit Graph

827 Commits

Author SHA1 Message Date
Nikita Kouevda
28d463f199 mv restore into gitgutter#utility#system 2023-08-31 07:50:14 -07:00
Nikita Kouevda
a5e0740801 Restore v:shell_error in autocmd ShellCmdPost
Fixes #869.
2023-08-30 23:43:30 -07:00
Andy Stewart
5f525476f3 Fix <Esc> in nvim floating preview window closes it
Previously the mapping was set in the original window not the floating
window, so <Esc> in the floating window did nothing (when it should have
closed it) while <Esc> in the original window closed the floating window
(when it should have done nothing).

Fixes #868.
2023-08-17 14:14:45 +01:00
Andy Stewart
a7a83c376c Fix closing floating preview window
When a floating window is closed, the cursor automatically goes back to
the original window.  There is no need to try to do this ourselves.

Fixes #866.
2023-08-17 13:45:56 +01:00
Andy Stewart
68f16eb21f Fix handling of file renames
Both `:file` and `:saveas` rename the current file.

`:file` does not write the newly named file to disk, and keeps the same
buffer.  It fires a single `BufFilePre` / `BufFilePost` pair of
autocommands:

    `BufFilePre`     buffer
    `BufFilePost`    buffer

`:saveas` does write the newly named file to disk, in a new buffer.  It
fires two pairs of `BufFilePre` / `BufFilePost` autocommands:

    `BufFilePre`     original buffer
    `BufFilePre`     new buffer
    `BufFilePost`    original buffer
    `BufFilePost`    new buffer

In both cases the cached path needs to be cleared.

See #860, #551.
Fixes #865.
2023-07-31 13:37:11 +01:00
Andy Stewart
458603713d Cast variable getter to match setter 2023-07-31 12:40:24 +01:00
Andy Stewart
8a2f8199b6 Document 'updatetime' and 'signcolumn' more prominently 2023-07-14 14:29:31 +01:00
Andy Stewart
4a7ca061af Add test for dos noeol
See #862.
2023-06-16 09:53:57 +01:00
Andy Stewart
422e4caf79 Ensure inline test functions can be redefined 2023-06-16 09:48:53 +01:00
Andy Stewart
f46652da18 Restore test teardown line
This was accidentally left commented out in the previous commit.
2023-06-16 09:48:53 +01:00
Adam Tao
883d60ec0e fix(diff): Wrong diff if dos format combines with noeol
If fileformat is dos and eol is not set, then a '\r' (but without '\n')
will be written to the last line of temporary buffer file, which will
confuse git and make git think all lines are modified. Fix it by adding
'r' to all lines except the last one if fileformat is dos and eol is not
set.

Suggested-by: Andy Stewart <boss@airbladesoftware.com>
Signed-off-by: Adam Tao <tcx4c70@gmail.com>
2023-06-16 09:44:05 +01:00
Andy Stewart
e2056e54c5 Add test for clean/smudge filter
See #796.
2023-06-05 10:52:10 +01:00
Andy Stewart
a202921235 Write buffer before staging whole file
We stage the whole file with `git-add` so we must ensure the file on
disk reflects the buffer's contents.

See #796.
2023-06-05 10:50:17 +01:00
Andy Stewart
278b393e68 Avoid unnecessary concatenation
This is simply to avoid double spaces in the generated commands.  Double
spaces make no practical difference but look slightly inelegant.
2023-06-05 09:52:56 +01:00
Andy Stewart
6ebc0fd233 Extract function to reduce duplication 2023-06-05 09:50:17 +01:00
Andy Stewart
3531f4eddd Remove obsolete link 2023-06-03 15:56:31 +01:00
Andy Stewart
7d425ff4b9 Use filename not path in git add
Since we change directory to the file's directory we can use its name
rather than its path in the repo.
2023-06-03 10:28:47 +01:00
Andy Stewart
f7f1286aac Use filename in clean_smudge_filter_applies() function
And move function to utility.

Since we change directory to the file's directory we can just use its
name rather than it path from the repo root.
2023-06-03 10:26:32 +01:00
Andy Stewart
cefbe30aa9 Make filename() function public 2023-06-03 10:22:20 +01:00
Andy Stewart
a483abb5fc Add timestamp to session log header 2023-06-03 10:09:53 +01:00
Andy Stewart
621b9e77ff Avoid :redir inside execute()
This was happening when starting vim with `let g:gitgutter_log = 1`
and generated E930.
2023-06-03 09:56:17 +01:00
Andy Stewart
538fba90fb Mention clean/smudge filters in readme
See #796.
2023-06-02 16:11:42 +01:00
Andy Stewart
885538efcd Stage entire file if clean/smudge filter applies
If a file is subject to a clean/smudge filter, it is impossible to stage
an individual hunk.  Therefore if the user tries to stage a hunk, ask
whether they want to stage the entire instead.

Determining whether a clean/smudge filter applies is done with:

    git check-attr filter -- path/to/file

– and looking for "unspecified" (not to be) in the output.  The result
is cached so that for a file which is not filtered (the common case),
staging multiple hunks only incurs the cost of the external call once.

See #796.
2023-06-02 16:01:51 +01:00
Andy Stewart
4ec072df23 Enable text conversion in git-show
This tells git-show to output the smudged version of a file if a
clean/smudge filter is defined for it.  In turns this allows us to diff
the buffer contents (which is smudged) against the reference version.

However patches cannot be applied.

See the man pages for git-show and gitattributes for more information.

See #796, #435.
2023-06-02 09:59:24 +01:00
Andy Stewart
11d6e13194 Ensure staging from preview always stages into correct file
Fixes #785.
2023-06-01 14:59:56 +01:00
Andy Stewart
ef978c745f Make preview use 'wrap' option of source window
Fixes #859.
2023-06-01 14:35:04 +01:00
Andy Stewart
8a95900cf1 Remove redundant comment 2023-06-01 09:25:54 +01:00
Andy Stewart
8d659d3dfc Declare similar autocmds next to each other 2023-06-01 09:25:43 +01:00
Andy Stewart
250112fecf Check before enabling after disabling for autocmds
Fixes #860.
See #551, #801.
2023-06-01 09:21:52 +01:00
Andy Stewart
2ee95686c5 Handle file which does not exist in diff base
If g:gitgutter_diff_base has been set and the file being processed does
not exist in that branch/commit, ensure that every line is marked as
added - this is how git-diff behaves.

Fixes #855.
2023-04-27 16:16:54 +01:00
Yuxin Wu
3475e974d6 Link highlight of GitGutterChangeDeleteLine to GitGutterChangeLine 2023-04-27 14:01:12 +01:00
Andy Stewart
44dbd57dd1 Document how to override defaults in g:gitgutter_floating_window_options
Closes #851.
2023-03-16 09:48:08 +00:00
woodyZootopia
3d29f67380 Add TabLeave to hunk close trigger
See #852
2023-03-13 15:55:22 +00:00
Andy Stewart
edb607cc4b Refresh signs after undoing a hunk
Fixes #850.
2023-02-24 11:56:39 +00:00
woodyZootopia
00df1089b6 Fix calculation of screen width
See #846.
2022-12-21 14:21:09 +00:00
Andy Stewart
400a12081f Fix calculation of non-floating preview window height
See #775, #846.
2022-10-22 17:52:39 +01:00
Andy Stewart
d4a3462df6 Extract function to calculate screen lines and cols
See #846.
2022-10-22 17:51:34 +01:00
Andy Stewart
24353971b9 Make height of floating preview window wrap-aware
Fixes #846.
2022-10-22 17:40:27 +01:00
Andy Stewart
f19b620319 Fix patch strings to use conventional format
See #841.
2022-08-24 14:29:47 +01:00
Andy Stewart
52d0066823 Ensure older vims process buffer at startup
In this context older vims are those without timer_start() and lambda.

The plugin always used to process the buffer at startup.  Then in #734
an optimisation was introduced to defer processing at startup, to keep
vim's startup fast.  However in this optimisation older vim's
unintentionally lost their startup processing altogether.
2022-08-22 09:42:07 +01:00
Andy Stewart
7808c48c7b Use timer instead of autocmd to defer startup processing
If the user has removed the "gitgutter CursorHold" autocommand, which
is the documented way to turn off automatic refreshing, calling the
autocommand at start up will fail.  Use a timer instead.

This implementation also changes the processing delay to 1ms instead of
'updatetime'.

See #840.
2022-08-22 09:30:47 +01:00
Andy Stewart
ded11946c0 Fix comparison to be case sensitive
Closes #836.
2022-05-24 09:24:40 +01:00
Andy Stewart
719d4ec06a Set filetype in :GitGutterDiffOrig
Closes #833.
2022-05-04 13:32:24 +01:00
Andy Stewart
988a6dbad9 Use a reliable regexp operator for lower case
It turns out =~ depends on 'ignorecase'.  Big sigh.
2022-04-25 20:41:43 +01:00
Andy Stewart
57000a73ab Use reliable regexp character class for lower case
It turns out [:lower:] does not always mean lower case (it depends
on 'ignorecase').  Sigh.
2022-04-25 20:26:21 +01:00
Andy Stewart
774add0c59 Improve testing of private functions 2022-04-25 13:47:08 +01:00
Andy Stewart
5dd8ab6211 Fix parsing of 'git ls-files -v' for filenames with spaces
Fixes #829.
2022-04-25 13:33:45 +01:00
Andy Stewart
2f359076bc Whitespace 2022-04-23 08:30:47 +01:00
Andy Stewart
626541edeb Heeds git's "assume unchanged" bit
I.e. does not diff files which should be assumed unchanged.

See:

    git update-index --[no-]assume-unchanged -- <file>
    git ls-files -v

Closes #826.
2022-04-23 08:25:46 +01:00
Andy Stewart
d5bae10403 Add GitGutterDiffOrig command
Closes #827.
2022-04-15 14:13:51 +01:00