1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-06 22:33:07 +02:00

2799 Commits

Author SHA1 Message Date
3d703bc9b9 Show hint about hunk staging mode being the default now, and how to switch to line mode
It is shown the first time the user enters either staging or patch building.
2025-08-01 10:35:17 +02:00
eb41bd2af2 Change the "toggle hunk selection" binding description to be dynamic
When the useHunkModeInStagingView config is on and you enter the staging view
with hunk selection enabled, it is confusing to see "a: Select hunk" in the
options view at the bottom.
2025-08-01 10:35:16 +02:00
75afa099e9 Add support for dynamic binding descriptions 2025-08-01 10:35:16 +02:00
9eb1e3a729 Add a GetShortDescription() method to Binding 2025-08-01 10:35:16 +02:00
d0438b7d33 Cleanup: better receiver name
No need for this to be uppercase.
2025-08-01 10:35:16 +02:00
d0a10bafbd Close a task's stdout pipe when we are done with it
This is similar to what we do when running tasks in a pty (we close the pty
there), and it should cause the called command to terminate.
2025-08-01 10:32:46 +02:00
20517330b4 Change GetCommitsOptions.RefForPushedStatus to a models.Ref
This makes it easier to use the full ref in the git merge-base call, which
avoids ambiguities when there's a tag with the same name as the current branch.

This fixes a hash coloring bug in the local commits panel when there's a tag
with the same name as the checked out branch; in this case all commit hashes
that should be yellow were painted as red.
2025-07-31 15:26:19 +02:00
4b9921d0a4 Move the Ref interface from gui/types to models
This is a type that can be useful for model/backend stuff, so move it there. We
are going to use it in the API of the commit loader.
2025-07-31 15:21:34 +02:00
abb7bed0c4 Draw divergence from base branch right-aligned in branches view
Also, remove it from the status view. I'd say it isn't really needed there,
although I don't have a strong opinion about that.
2025-07-30 14:23:31 +02:00
9c0e103b90 Stage only tracked files when staging all in filter-by-tracked-files view
Also, fix two other commands that stage all files under the hood:
- when continuing a rebase after resolving conflicts, we auto-stage all files,
  but in this case we never want to include untracked files, regardless of the
  filter
- likewise, pressing ctrl-f to find a base commit for fixup stages all files for
  convenience, but again, this should only stage files that are already tracked
2025-07-28 14:10:38 +02:00
151e80902e Use a different way to check if a tag is annotated
Storing it in the Tag struct makes loading tags a lot slower when there is a
very large number of tags; so determine it on the fly instead. On my machine,
the additional call takes under 5ms, so it seems we can afford it.
2025-07-28 10:53:51 +02:00
52be6964ed Allow rewording and dropping commits in filtering mode
There's no reason not to allow these.

Technically we could enable a few more, but I chose not to because some might be
surprising or confusing in filtering mode. For example, creating a fixup commit
would work (shift-F), but the newly created commit might not show up if it
doesn't match the filter. Similarly, pressing `f` to fixup a commit into its
parent would work, but that parent commit might not be visible, so users might
expect to be fixing up into the next visible commit.
2025-07-27 12:48:38 +02:00
6976d38586 Inline the OutsideFilterMode guard into every binding
The reason for doing this is that we want to remove the guard from some of
these, but we don't want to change the order.
2025-07-27 12:48:38 +02:00
0cfe42b43f Show the key for focusing the main view ("[0]" by default) in the main view title prefix
We show it only if the "showPanelJumps" config is on, although the
focus-main-view command is not technically part of the panel jump keys; but it
looks similar.
2025-07-27 12:28:06 +02:00
72a8e8194d Fix display of panel jump keys for disabled bindings 2025-07-27 12:27:56 +02:00
b9f4c43695 Allow focusing the main view for the status panel
I left this out originally because it's not needed for the status "dashboard"
view (except on really tiny screens); however, it *is* useful after pressing `a`
to show the all branches log, and even more so for people who use the
"statusPanelView: allBranchesLog" config. And it doesn't really hurt for the
dashboard view either, so just enable it always rather than making a distinction
which view we are showing.
2025-07-27 12:27:35 +02:00
837efd95e2 Move the "Focus main view" command to the global section of the keybindings menu 2025-07-27 12:25:16 +02:00
96a6e659a6 Make LabelFromKey return an empty string for unset keys
It previously returned "\x00", which is probably not intended, but happened to
work.
2025-07-27 12:25:16 +02:00
7fe96e9aee Include commands without keybinding in options menu
This is not a behavior change, we already include these in the menu, but that's
because of a bug that we will fix in the next commit.

I find it useful to see these commands, especially for rarely-used custom
commands that you don't want to waste a keybinding on.
2025-07-27 12:25:16 +02:00
c5acad777d Don't use hunk mode for added or deleted files
When entering staging (or patch building) for an added or deleted file, it
doesn't make sense to use hunk mode, because pressing space would stage/unstage
the entire file, and if the user wanted to do that, they would have pressed
space in the Files panel. So always use line mode for added/deleted files by
default, even if the useHunkModeInStagingView user config is on.
2025-07-27 12:10:25 +02:00
a1aeedd5d5 Fix showing range diff across a rename when filtering by path
We need to pass the union of filter paths at both ends of the range.
2025-07-27 12:05:41 +02:00
0f7f1a56df Fix showing diffs for renamed file when filtering by path
When filtering for a file path we use the --follow option for "git log", so it
will follow renames of the file, which is great. However, if you then selected
one of the commits before a rename, you didn't see a diff, because we would pass
the original filter path to the "git show" call.

To fix this, call git log with the --name-status option when filtering by path,
so that each commit reports which file paths are touched in this commit;
remember these in the commit object, so that we can pass them to the "git show"
call later.

Be careful not to store too many such paths unnecessarily. When filtering by
folder rather than file, all these paths will necessarily be inside the original
filter path, so detect this and don't store them in this case.

There is some unfortunate code duplication between loading commits and loading
reflog commits, which I am too lazy to clean up right now.
2025-07-27 12:05:41 +02:00
33a4fdf0ee Remove unnecessary setSubCommits indirection
I don't know why this function argument was added, but I don't like unnecessary
indirections, so I'm removing it as SubCommitsHelper has access to everything it
needs to do it itself.
2025-07-27 12:05:41 +02:00
e1d728ee5e Fix showing only filtered reflog entries when filtering by path
Recycle reflog commits only for the non-filtered ones.

If we're not filtering, FilteredReflogCommits and ReflogCommits are the same. If
we then enter filtering and get reflog entries again, and pass a
lastReflogCommit, we'd recycle the previous FilteredReflogCommits, which are
unfiltered, so that's no good. Work around this by simply never using the
recycle mechanism when getting the filtered reflog commits.

We could do better by remembering what the last filter path or author was, and
only suppressing the recycling when it changed; but that's more complexity than
I want to add, so hopefully this is good enough.
2025-07-27 12:05:41 +02:00
934276ac40 Use the non-filtered reflog for undoing
Using the filtered one is probably not a good idea. It didn't do much harm
because the split of ReflogCommits and FilteredReflogCommits doesn't really work
right now (FilteredReflogCommits is always the same as ReflogCommits, even in
filtering mode), but we'll fix this in the next commit.
2025-07-27 12:05:41 +02:00
d99ceb91ee Don't get reflog commits twice unnecessarily in filtering mode
I can only guess what happened here: in aa750c0819, this code to manually load
the reflog commits was added, to make sorting branches by recency work when the
reflog is filtered by path. At that time we didn't have separate ReflogCommits
and FilteredReflogCommits models yet. Then, FilteredReflogCommits was introduced
(in 8822c409e2), probably for the very purpose of being able to get rid of this
again; but then it was forgotton to actually get rid of it.

The funny thing is that the introduction of FilteredReflogCommits happened in
the very next commit, 15 minutes later.
2025-07-27 12:05:41 +02:00
5e65e8e0ea Refresh all affected scopes when entering/exiting filtering
Since filtering switches to half-screen mode in the local commits panel, most
people probably didn't notice, but we do also filter those other views. So when
leaving half-screen mode (but not filtering), you could switch to sub-commits or
stashes, and those would show the filtered view only after the next refresh
(e.g. after a background fetch). It's worse when leaving filtering, because this
goes back to normal screen mode, and you would often see an empty stashes panel
after that (until the next background fetch), which is quite confusing.

I also find it questionable to always switch focus to the commits panel when
entering filtering. If it is initiated from subcommits, reflog, or stashes,
maybe we want to stay there. I'm not changing this now since I'm unsure how much
people rely on the current behavior.
2025-07-27 12:03:06 +02:00
5307999874 Allow passing SUB_COMMITS scope to Refresh when no subcommits view is showing
We don't currently do this, but will in the next commit; it's a reasonable thing
to want to do, and it shouldn't crash.
2025-07-27 12:03:06 +02:00
e5c39d5401 Fix visual regression when exiting filtering mode
When exiting filtering mode while the focus is not in the local commits panel,
the call to HandleFocus would render the selection in the commits panel as if
the panel had the focus.

The call to HandleFocus was introduced recently in 4981419ba9 in an attempt to
rerender the main view correctly, but it should only have been called when local
commits is the focused context. But instead, we can use PostRefreshUpdate, which
handles this distinction.
2025-07-27 12:03:06 +02:00
69567063f4 Support Alt+Backspace for word deletion in text areas
Add support for Alt+Backspace (Option+Backspace on macOS) to delete
entire words in text input areas, matching common text editor behavior.
2025-07-17 19:13:25 +02:00
238fdd573c Add confirmation for nuking the working tree 2025-07-13 14:04:14 +02:00
5b1292006d Add new command "Checkout previous branch" 2025-07-12 18:17:25 +02:00
2b41a27d92 Fix search results being off by two lines during rebase or in divergence view
We forgot to convert the model indices to view indices in searchModelCommits.
This needs to be done for search results to be highlighted correctly in the
"divergence from upstream" view, which adds "--- Remote/Local ---" entries, and
during a rebase, where we have "--- Pending rebase todos ---" and "--- Commits
---" which offset view indices from model indices.
2025-07-12 17:30:36 +02:00
dd47ef7354 Make prepareConversionArrays a little more concurrency safe
I have seen cases where during a rebase (two nonModelItems) all entries in
viewIndicesByModelIndex beyond the second nonModelItem were off by 4 rather than
2 as I would expect. The only explanation I have for this is that the function
was called concurrently.

Improve this by working on a local variable and only assign to self at the end;
this is not a real fix for the concurrency issue of course, but it makes it much
less likely to be a problem in practice.
2025-07-12 17:25:35 +02:00
9baf787059 Allow double-clicking suggestions 2025-07-11 11:18:28 +02:00
3ff4552960 Allow switching between confirmation and suggestions by clicking
This is very similar to what we are doing to allow switching between commit
subject and description in the commit message editor.
2025-07-11 11:18:28 +02:00
21dd901bd9 Extract helper function 2025-07-11 11:18:28 +02:00
8ad2637715 Allow scrolling background views with the mouse wheel when a popup is showing
I see little reason to suppress this; the check was really only for click
events, not wheel events.
2025-07-11 11:18:28 +02:00
f6c20f2745 Cleanup: use FocusedView property for mouse bindings
This way the click is only handled if a given view has the focus, and we don't
have to check this manually in the handler.
2025-07-11 11:18:28 +02:00
2e5cf46716 Make conditions easier to understand
This doesn't change behavior, just makes the code a little bit easier to
understand: the outermost condition is "do we show a popup and is the mouse
event for some other view than the focused one". Only if that's true do we need
to define the isCommitMessageView function, and check whether both views belong
to the commit message editor.
2025-07-11 11:18:28 +02:00
4a6041f3ce Exclude "." from file path suggestions
It looks funny and doesn't have any value.
2025-07-11 11:18:28 +02:00
fee5794c83 Remove outdated comment
Maybe I'm misunderstanding what the comment was supposed to mean, but we do show
all paths if nothing has been typed.
2025-07-11 11:18:28 +02:00
37197b8e9a Add proper double-click handling for list views
Previously a click was detected as a double-click whenever the click was on the
already selected line, regardless of how long ago the last click was (or even
when it wasn't selected by clicking at all). Now that gocui supports proper
double-click detection, we can do better.
2025-07-11 10:52:57 +02:00
12df9d2b42 Assert that only one controller can set click or render functions on a BaseContext
The rationale for this is the same as in the previous commit; however, for these
functions we only allow a single controller to set them, because they are event
handlers and it doesn't make sense for multiple controllers to handle them.
2025-07-11 10:52:57 +02:00
4dfa4e8aa2 Allow more than one controller to attach OnFocus/OnFocusLost functions
Trying to do this would previously have the second one silently overwrite the
first one's.

We don't currently have this in lazygit, but I ran into the situation once
during development, and it can lead to bugs that are hard to diagnose.

Instead of holding a list of functions, we could also have added a panic in case
the function was set already; this would have been good enough for the current
state, and enough to catch mistakes early in the future. However, I decided to
allow multiple controllers to attach these functions, because I can't see a
reason not to.
2025-07-11 10:51:44 +02:00
9c5c459faa Cleanup: use nil for empty slice 2025-07-11 10:47:07 +02:00
b3ca944c9e Remove GetOnRenderToMain, GetOnFocus, and GetOnFocusLost from BaseContext
These are never called on the context, they only exist to satisfy the
HasKeybindings interface. But that's wrong, HasKeybindings has nothing to do
with focus handling or rendering the main view. Remove them from that interface
and add them to IController instead.
2025-07-11 10:47:07 +02:00
4981419ba9 Fix stale main view content when entering/exiting filtering view
When entering filtering we would only call FocusLine, which takes care of
highlighting the selected line in the commits list, but not of re-rendering the
main view. HandleFocus does that.

When exiting filtering, the HandleFocus call was missing entirely.

The tests needed to be reworked a little bit to make this testable.
2025-07-09 16:00:46 +02:00
df48667253 Add a prompt for the sort order menus for branches 2025-07-09 13:16:42 +02:00
6bfcb3d6f0 Add tooltips for commit log menu 2025-07-09 13:16:42 +02:00