107 Commits

Author SHA1 Message Date
Touko Hallasmaa
d3a9986fe8 Fix moving to floating window 2025-03-07 09:39:31 +00:00
Andy Stewart
bed580ab8b Use git -C instead of cd 2024-07-13 06:20:56 +01:00
Luke Davis
e801371917 Respect &foldopen during next/prev hunk jumps 2024-04-29 20:55:22 +01:00
Nikita Kouevda
28d463f199 mv restore into gitgutter#utility#system 2023-08-31 07:50:14 -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
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
6ebc0fd233 Extract function to reduce duplication 2023-06-05 09:50:17 +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
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
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
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
774add0c59 Improve testing of private functions 2022-04-25 13:47:08 +01:00
Alexander Courtis
e433d5ddc1 #816 do not modify previewpopup when it does not exist 2022-02-19 13:37:19 +00:00
Andy Stewart
54b94f98de Prevent 'previewpopup' from breaking hunk previews
See #809.
2022-02-02 10:01:06 +00:00
Andy Stewart
384bf003f6 Allow configuration of floating window appearance
Closes #807.
2022-02-02 09:23:45 +00:00
Andy Stewart
68a8cb300c Close preview on escape: only map <Esc> while preview open
This only applies to floating preview windows on Neovim.

Handles the following way of closing the floating preview:

- <Esc>
- Moving cursor
- 2<C-W>c (where 2 is the floating window's window number)
- <C-W><C-W> to move into and out of the floating window

Closes #786.
2021-06-03 12:23:58 +01:00
Andy Stewart
2571c8f520 Enable is_preview_window_open() to handle floating windows
See #784.
2021-06-02 11:52:37 +01:00
Andy Stewart
5b4ec87517 Expose is-open and close hunk-preview-window functions
This allows custom maps for closing the hunk preview window.

See #784.
2021-06-02 11:49:42 +01:00
Andy Stewart
d13d58a35f Clear unwanted characters in nmap
See #784.
2021-06-02 11:44:18 +01:00
Andy Stewart
f4bdaa4e9c Remove useless comparison 2021-04-22 19:41:59 +01:00
Andy Stewart
66bafa5348 Update open preview on hunk jump
See #396, #779.
2021-04-22 15:42:45 +01:00
Andy Stewart
e288dd4733 Suppress echoing of preview window file name
The file name does not mean anything so it is unhelpful to show it.
Not showing it avoids the hit-enter prompt which can occur.
2021-04-22 15:37:28 +01:00
Vincent Cordobes
42ed714fb9 Capitalize warning messages 2021-04-22 12:03:06 +01:00
Andy Stewart
9756e95bd5 Fix resizing of existing non-floating hunk preview window
This bug was introduced by 9784226 in #708.  It had the effect of not
allowing an existing hunk preview window to increase in size for a
larger hunk (up to 'previewheight').

See #775.
2021-04-13 15:18:27 +01:00
Andy Stewart
24cc477895 Avoid cursor in unexpected window after Esc in preview
Thanks @andymass for the patch.

See #769.
2021-03-19 16:31:26 +00:00
Andy Stewart
64062dfe02 Simplify opening of preview window 2021-03-16 12:06:31 +00:00
Andy Stewart
f3145958dd Make statusline blank in hunk preview window
I would prefer to remove the statusline altogether in the hunk preview
window, making it consistent with the floating preview window.  However
I do not think that is possible; the best one can do is make it blank.
2021-03-15 17:00:33 +00:00
Andy Stewart
6019d43860 Ensure hunk summary is updated during a hunk op
Fixes #765.
2021-02-16 16:04:47 +00:00
Andy Stewart
f440ed04dd Enable <Esc> to close floating preview window
See #718.
2021-02-08 12:48:01 +00:00
obcat
0cbe0f392d Prevent hunk preview using preview window from changing alternate file 2021-02-06 11:37:12 +09:00
obcat
987a33355e Show message like "Hunk 4 of 11" after hunk jumping 2020-11-05 16:43:52 +00:00
Andy Stewart
62ff20f979 Return early when pre-condition not met 2020-07-28 10:16:47 +01:00
Andy Stewart
63941de9f9 Distinguish no hunks at all from no further hunks
Closes #709.
2020-07-28 10:12:48 +01:00
Andy Stewart
51a03d4ae0 Add option for <Esc> to close non-floating preview window
Closes #718.
2020-06-23 15:18:25 +01:00
Andy Stewart
97a24e903a Reset any existing preview window
When previewing a hunk we re-use any existing preview window.  However
we need to reset it for our purposes in case it was used in an
incompatible way before.

See #713.
2020-06-18 09:38:43 +01:00
Andy Stewart
e31e9bb35f Avoid E315 when populating Neovim floating preview window
Fixes #711.
2020-06-10 09:13:35 +01:00
Andy Stewart
9784226ba7 Account for wrapping when resizing preview window
Fixes #708.
2020-05-29 10:46:42 +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
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