Commit Graph

268 Commits

Author SHA1 Message Date
Andy Stewart
dab840b153 Use fresh temp files for every diff
Originally the plugin used fresh temp files for every diff.  But it
wrote to those files with `:write` which made Vim's buffer numbers
increase unnecessarily (see #297) so the plugin changed to reuse the
same temp files each time (see a871d857).

However this has the problem that after Vim has been open for a while,
e.g. a few days, the operating system can clean up the temp directory
holding those temp files.  The next time the plugin runs a diff, Vim
throws an error because it cannot write to the temp files because their
directory has disappeared (see #395, #433).

In the meantime the plugin changed how it writes the temp files to
use `writefile()` (see 4e911819).  This removed the problem of rapidly
increasing buffer numbers.

Now the buffer number problem has gone, the plugin can revert to using
fresh temp files each time.
2020-04-23 16:47:03 +01:00
Andy Stewart
425c7cf2e2 Maintain backward compatibility in hunk preview code
win_getid() was introduced in Vim 7.4.1557.  The code uses it to
remember the id of the preview window.  In newer Vims or Neovim this
could be a floating window but pre-7.4.1557 it can only be an ordinary
preview window.  And in that case we only need the preview window's
buffer number.

This commit uses the buffer number when win_getid() isn't available.

Fixes #683.
2020-04-23 09:28:38 +01:00
Andy Stewart
3599736179 Fire GitGutterStage User event after staging
Closes #698.
2020-04-23 08:59:26 +01:00
Andy Stewart
2b62481d38 Only diff against parent commit in Fugitive revision buffers
Fixes #695.
2020-04-18 17:13:15 +01:00
Andy Stewart
5f6048da13 Bypass sticky type checking on older Vims
Until Vim 7.5.1546 the type of a variable could not be changed.

Fixes #693.
2020-04-14 15:42:07 +01:00
Andy Stewart
b7db78b258 Simplify getting and setting buffer variables
This also avoids the getbufvar(bufnr, '') pattern which is subject to a
Vim bug in certain versions.

Closes #691.
2020-04-03 14:50:15 +01:00
qlem
9cdb90b1e1 fix #688 2020-04-01 17:33:05 +01:00
qlem
262f1b5c9a keep noautocmd and fire WinEnter with a doautocmd 2020-04-01 13:07:03 +01:00
qlem
9c7f819538 fix the behavior of the status line of the hunk preview windows 2020-04-01 13:07:03 +01:00
Andy Stewart
0e509fb0ac Set diff base when viewing file versions with Fugitive
When you look at previous versions of a file, e.g. with Fugitive's
:0Gclog, gitgutter will set the diff base to the current version's
parent so that diff markers appear as expected.

Thannks to @rcreasi for the idea and initial implementation.
2020-03-12 10:38:58 +00:00
Andy Stewart
c337eef1b7 Make hunk commands noops when file not tracked by git
Fixes #680.
2020-02-24 15:42:05 +00:00
Andy Stewart
8e368ae8d1 Extract has_repo_path() function 2020-02-24 15:16:51 +00:00
Andy Stewart
669357bb92 Fix #repo_path() return value when path not set
This change makes it an empty string, as documented, not 0.
2020-02-24 15:10:55 +00:00
Daniel Hahler
da2c785221 Set scriptencoding for file with utf8 BOM 2020-02-13 11:25:10 +00:00
Daniel Wyatt
2ef4f7e7b2 Use known shell for git_supports_command_line_config_override. 2020-01-22 09:00:31 +00:00
Andy Stewart
5c73edb3c2 Fix write_buffer() to not add extra line for dos fileformat 2019-10-15 10:14:10 +01:00
Andy Stewart
320b7a33e7 Fix preview and undo hunk for dos line endings 2019-10-14 10:10:46 +01:00
Andy Stewart
0bcd8c5b9c Update signs if linenrs highlighted
Fixes #656.
2019-09-30 13:20:43 +01:00
Andy Stewart
32fb9895b7 Do not clear signs when disabling signs if linenrs highlighted 2019-09-30 13:20:17 +01:00
Andy Stewart
cc5108e9a7 Avoid unnecessary diff enabling signs when linenrs highlighted 2019-09-30 13:19:11 +01:00
Andy Stewart
178764e9a1 Whitespace 2019-09-30 13:17:23 +01:00
Andy Stewart
54eff3e545 Clarify variable name 2019-09-30 12:56:10 +01:00
Andy Stewart
44bb472bac Add changed indicator for closed folds
Closes #655.
2019-09-27 16:50:14 +01:00
Andy Stewart
6b08e1425b Include accumulated prefix offsets when recursing 2019-09-26 16:57:27 +01:00
Andy Stewart
09bc754efc Fix splitting on a string not a pattern 2019-09-26 16:56:19 +01:00
Andy Stewart
b94fab3070 Use matchaddpos() instead of text properties
matchaddpos() has better backward compatibility than text properties.  I
only used text properties inside Vim popups because I did not think
there was a way to use matchaddpos(), but then I found a way.
2019-09-26 15:08:56 +01:00
Andy Stewart
ba049e707a Add note 2019-09-24 18:38:54 +01:00
Andy Stewart
45347c9a4b Add comment 2019-09-24 18:38:36 +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
677a80c4ed Only show intra line highlights in Vim popups when supported 2019-09-24 11:25:48 +01:00
Andy Stewart
dfa6972b67 Add intra-line change highlighting for Vim popups 2019-09-24 11:07:29 +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
f980fab55c Do not enable syntax in Vim floating popup
Fixes #653
Closes #654
2019-09-23 10:33:17 +01:00
Andy Stewart
12bb0e9634 Do not write EOL after last line when no EOL present
See #650.
2019-09-19 12:20:42 +01:00
Andy Stewart
92deed378d Add cterm value for intra-line highlights 2019-09-18 15:54:21 +01:00
Andy Stewart
fdecc23368 Hunk previews highlight intra-line changes.
Closes #577.
2019-09-18 11:55:01 +01:00
Andy Stewart
0469b8435a Deprecate <Plug>... maps in favour of <Plug>(...) 2019-09-04 08:56:36 +01:00
Andy Stewart
43c82ce8fb Whitespace. 2019-09-03 13:53:52 +01:00
Andy Stewart
0804623cb7 Reset hunk previewing window's modified state. 2019-09-03 13:52:55 +01:00
Andy Stewart
558e51bd5c Avoid duplicate autocommands in previewing window. 2019-09-02 10:40:25 +01:00
Andy Stewart
c375aea57a Enable any write in hunk previewing window to stage. 2019-08-29 15:45:27 +01:00
Andy Stewart
8bafd08ef4 Support diffs relative to the working tree.
Closes #558.
2019-08-28 09:22:06 +01:00
Andy Stewart
afb8e03222 Do not run ex commands unnecessarily via normal mode. 2019-08-27 19:49:49 +01:00
Andy Stewart
67c8cca890 Support Vim's popup windows for hunk previews.
Note this prevents staging partial hunks via the previw window.
2019-08-27 16:56:30 +01:00
Andy Stewart
f0f56b9569 Use floating windows for hunk previews on Neovim. 2019-08-27 16:02:51 +01:00
Andy Stewart
0c3e7219b4 Extract operations on hunk preview window. 2019-08-27 11:52:50 +01:00