54 Commits

Author SHA1 Message Date
Andy Stewart
84bc2d68c0 Fix base_path() to handle filenames with colons
This bug was introduced when teaching gitgutter to handle file moves
in #872.

Fixes #877.
2024-01-03 16:06:27 +00:00
Andy Stewart
c3b99e52f5 Add test for file moves
See #872.
2023-11-10 12:42:19 +00:00
Andy Stewart
744a0fcd9e Add test for not clobbering v:shell_error
See #869, #870.
2023-09-01 10:15:55 +01:00
Andy Stewart
101e9ca217 Fix typo in test 2023-09-01 10:05:31 +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
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
Andy Stewart
e2056e54c5 Add test for clean/smudge filter
See #796.
2023-06-05 10:52:10 +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
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
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
7d9b7125ff Update quickfix test
See #789.
2021-07-12 11:22:11 +01:00
Andy Stewart
ed978c40eb Fix dos undo test 2019-10-15 10:14:00 +01:00
Andy Stewart
7e1ca55646 Fix test names 2019-10-15 10:13:02 +01:00
Andy Stewart
320b7a33e7 Fix preview and undo hunk for dos line endings 2019-10-14 10:10:46 +01:00
Andy Stewart
44bb472bac Add changed indicator for closed folds
Closes #655.
2019-09-27 16:50:14 +01:00
Andy Stewart
883b2be1db Test s:split does not use regex 2019-09-27 13:16:23 +01:00
Andy Stewart
6b08e1425b Include accumulated prefix offsets when recursing 2019-09-26 16:57:27 +01:00
Andy Stewart
f2ea4f7034 Fix missing empty string when LCS at one end 2019-09-24 18:38:12 +01:00
Andy Stewart
3405ad72b6 Handle edge case in common prefix calculation 2019-09-24 18:33:12 +01:00
Andy Stewart
ccd4972d23 Fix off-by-one error in LCS calculation 2019-09-24 17:10:26 +01:00
Andy Stewart
9231bda97f Enable intra-line highlights to handle multiple regions
For example consider:

    -The cat in the hat.
    +The ox in the box.

Before this change the highlights would be:

    -The cat in the hat.
         ^^^^^^^^^^^^^^
    +The ox in the box.
         ^^^^^^^^^^^^^

After this change the highlights are:

    -The cat in the hat.
         ^^^        ^^^
    +The ox in the box.
         ^^        ^^^

Another example; before:

    -The quick brown fox jumped
    +The (quick) brown (fox) jumped
         ^^^^^^^^^^^^^^^^^^^

And after:

    -The quick brown fox jumped
    +The (quick) brown (fox) jumped
         ^     ^       ^   ^
2019-09-24 10:26:31 +01:00
Andy Stewart
68e735b92c Improve intra-line change highlighting
Handle two insertions and two deletions.
2019-09-23 15:59:37 +01:00
Andy Stewart
ae9edf0602 Fix non-empty suffix condition 2019-09-23 13:19:49 +01:00
Andy Stewart
fdecc23368 Hunk previews highlight intra-line changes.
Closes #577.
2019-09-18 11:55:01 +01:00
Andy Stewart
88d396f1b4 Add :GitGutterQuickFix command.
It loads all hunks into the quickfix list.

Closes #617.
2019-08-28 11:59:19 +01:00
Andy Stewart
307caf6f39 Extract general assert method. 2019-08-28 11:56:52 +01:00
Andy Stewart
2364d14242 Fix test logic when no signs expected. 2019-08-28 11:41:09 +01:00
Andy Stewart
7dfbb8be11 Fix incorrect expectations in test. 2019-08-22 15:16:43 +01:00
Andy Stewart
5458e3db8a Use feedkeys() so cabbrev sees it. 2019-08-22 15:15:54 +01:00
Andy Stewart
77fb3fd81e Enable :w in preview window to stage the hunk. 2019-08-21 10:27:23 +01:00
Andy Stewart
cbaa22e38c Use sign functions, groups, and priority, where available.
On Vims that support it, signs are placed in the "gitgutter" group with
a priority set by g:gitgutter_sign_priority.

Closes #544.
Closes #576.
Closes #627.
2019-08-16 16:21:06 +01:00
Andy Stewart
070cfc531a Move to line more idiomatically. 2019-08-13 16:02:12 +01:00
Andy Stewart
b036fcf527 Stage part of any hunk.
See #279.
2019-08-13 15:57:22 +01:00
Andy Stewart
bc1d28db46 Allow staging part of an additions-only hunk.
See #279.
2019-08-12 17:19:05 +01:00
Andy Stewart
5bb4f14ed3 Fix tests in light of sign-priority. 2019-05-29 13:04:39 +01:00
Andy Stewart
1d422b9f98 Revert to non-binary writefile() for writing buffer.
The previous commit switched use of writefile() to binary mode so that
we could prevent a newline being added to a completely empty buffer.
Evidently, however, binary mode has side effects (see #567) so this
commit returns to non-binary mode - with a simpler fix for completely
empty files.

Unfortunately this implementation does not work for noeol files - see
the failing test - because writefile() does not take account of
'nofixeol' (unlike :write).  This is suboptimal but acceptable because
noeol files are not be encountered often.

See #567.
2018-12-15 14:55:14 +00:00
Andy Stewart
5c636b128e Fix handling of buffer consisting only of a newline.
See #510.
2018-12-13 10:50:02 +00:00
Andy Stewart
3f642a0bb8 Add assertion for path of untracked file. 2018-11-17 17:24:48 +00:00
Andy Stewart
947737c76f Handle non-ASCII paths.
This prevents git-ls-files from escaping "unusual" characters in
pathnames.  When this happened, gitgutter would feed the escaped name
back to git-show but git-show would not recognise it.

This commit makes git-ls-files use the -z option to output pathnames
verbatim.  These pathnames also become null terminated so we have to
ensure we remove the null terminator too.

Closes #562.
2018-11-17 11:24:36 +00:00
Andy Stewart
0597380f6b Prompt user to choose hunk when overlapping.
See #556.
2018-10-18 15:39:55 +01:00
Andy Stewart
89c34f74cb Display unambiguous sign when hunks overlap.
See #556.
2018-10-18 09:45:55 +01:00
Andy Stewart
a7206c41fc Add test for files with leading dash. 2018-05-08 16:26:48 +01:00
Andy Stewart
72226496b3 Add test for encoding conversion. 2018-03-14 14:44:33 +00:00
Andy Stewart
5db4a3a2a5 Make robust the replacement of temp file paths with actual paths.
The previous implementation meant the temp file paths were treated as
regular expressions, which was vulnerable to problems with backslashes
etc.

See #494.
2018-03-02 12:44:49 +00:00
Andy Stewart
e9aee00190 Switch off diff.mnemonicPrefix in tests.
Follows on c325a8b.
2018-02-22 11:04:10 +00:00
Andy Stewart
798abe53b3 Extract helper for triggering gitgutter. 2018-02-21 11:33:44 +00:00
Andy Stewart
35c92dbd50 Add test for user autocmd. 2018-02-21 11:31:48 +00:00