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

6686 Commits

Author SHA1 Message Date
37d5aeea8b Remove unnecessary golangci-lint install step from dev-container Dockerfile 2025-07-18 15:36:43 +02:00
c8a1e894e0 Remove unused script lint.sh 2025-07-18 15:33:23 +02:00
38fc107f94 Use a better way of pinning the version of golangci-lint
Instead of requiring the user to install the right version of the tool in their
.bin folder, create a shim that automatically runs the right version of the
tool. This has several benefits:
- it works out of the box with no setup required (the tool will be automatically
  downloaded and compiled the first time it is used)
- no work needed for developers when we bump the golangci-lint version
- it works in working copies that are used in different environments (e.g.
  locally on a Mac, or inside a dev container)

Co-authored-by: kyu08 <49891479+kyu08@users.noreply.github.com>
2025-07-18 15:33:23 +02:00
d159b28dc0 Support Alt+Backspace for word deletion in text areas (#4741)
- **PR Description**
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:20:52 +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
1210a645ef Fix amending commits whose commit message is empty (#4732)
- **PR Description**

When the commit message is empty, the `--amend` command will produce an error.
Solution: Add the `--allow-empty-message` option.
2025-07-14 18:00:12 +02:00
0451a16510 Fix --amend when the commit message is empty 2025-07-14 17:58:31 +02:00
9625ee8a59 Add confirmation for nuking the working tree (#4727)
- **PR Description**

This is a small PR that extends the logic added in
https://github.com/jesseduffield/lazygit/pull/4704

There were many reports of users accidentally resetting the working tree
using the reset commands and a nice change was added by @stefanhaller to
prompt for confirmation on those actions but the "Nuke working tree"
option was not covered by the PR.

I believe this one is actually one of the most important options to
prompt because it's by default the first one on the list. I myself
triggered it once when trying to discard a single file while unknowingly
having caps-lock enabled as I thought I was confirming the single file
discard option.
2025-07-13 15:01:22 +02:00
238fdd573c Add confirmation for nuking the working tree 2025-07-13 14:04:14 +02:00
1795cb9315 Add new command "Checkout previous branch" (#4728)
## **PR Description**
I added a new feature to checkout to the last branch.
I think it would be convenient to be able to checkout to the last branch
with just one key stroke(`-`) in some cases, such as when switching
between multiple branches during code review.

Off course, I know that you can same thing by entering `"-"` to the text
input of "Checkout by name" or using custom command but I think `git
checkout -` is occasional use case. So I feel this feature can be a part
of default features.

Another advantage of this feature is that you can checkout to the last
branch regardless of cursor position.
Being able to switch branches without worrying about cursor position
reduces stress I think.
2025-07-12 18:20:11 +02:00
d41668f565 Fix last branch to previous branch in TranslationSet.CheckoutByNameTooltip 2025-07-12 18:17:45 +02:00
c75d92f270 Update cheatsheets and schema 2025-07-12 18:17:45 +02:00
5b1292006d Add new command "Checkout previous branch" 2025-07-12 18:17:25 +02:00
7d92260050 Fix commit searching during rebase or in divergence from upstream view (#4730)
- **PR Description**

Fix search results being off by two lines during a rebase or in the
divergence from upstream view.
2025-07-12 17:36:26 +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
228d4428ca Improve mouse handling of suggestions panel (#4726)
- **PR Description**

In prompts with a suggestions panel (e.g. the "Execute shell command"
window, or the "Filter by path" panel), you can now
- scroll the list of suggestions with the mouse wheel even when the
  focus is in the edit field
- click in the suggestions list or in the edit field to switch focus
  between them
- double-click a suggestion to trigger it
2025-07-11 11:26:39 +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
43b379fb09 Detect double-clicks properly (#4725)
- **PR Description**

Previously, any click on an already selected line in a list view was
treated as a double click, and triggered the same action as pressing
either enter or space, depending on the view. Improve this by doing
proper double-click detection based on how much time has passed between
clicks.

Fixes #2526.
2025-07-11 11:18:03 +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
0245d663c0 Bump gocui 2025-07-11 10:26:09 +02:00
c2aab81f54 Fix more unstable tests (#4721)
Similar to what was done in 457cdce61d, and for the same reason.
2025-07-10 09:02:41 +02:00
bf19475733 Fix more unstable tests
Similar to what was done in 457cdce61d, and for the same reason.

However, instead of waiting and fixing them one by one as we see them fail, I
decided to go about it more systematically. To do that, I added calls to
`time.Sleep(1 * time.Second)` in all the Shell.Commit* helper functions; this
ensures that all the commits we make get different committer time stamps, making
all these tests fail. With this I'm pretty confident that we're good now.
2025-07-10 08:59:01 +02:00
656cb3203c Fix stale main view content when entering/exiting filtering view (#4719)
- **PR Description**

When filtering by path, the main view wouldn't update the diff properly
when entering and exiting the filtering mode.
2025-07-09 16:03:54 +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
457cdce61d Fix unstable tests
Now that -committerdate is the default sort order, we could get different
results for the sort order of the branches list depending on whether the commits
on both branches have the same committer time stamp (likely in an integration
test, since git time stamps have second resolution), in which case git will fall
back to alphabetical order, or not (rare, but possible), in which case master
will have the newer commit and will come first. Make this stable by forcing the
sort order to alphabetical.

We might have more tests with this problem, we'll just have to fix them one by
one as we see them fail.
2025-07-09 16:00:46 +02:00
8026fc2bb9 Provide user config defaults for UI-changeable settings (#4717)
As discussed in #4602, we make a general change to how we treat UI
settings that can be changed from within lazygit; previously, the rule
was to persist them in State.yml so that they automatically remember the
last value that was set in the UI; now, we no longer do this, and
instead provide user configs for setting defaults which we fall back to
on every start.

See #4602 for an in-depth discussion about the pros and cons of either
approach, and why we chose this one.

As part of this, we change the default for the sort order of branches to
date (aka committerdate), both for local and for remote branches (was
recency and alphabetical before, respectively). See the discussion
starting
[here](https://github.com/jesseduffield/lazygit/pull/2147#issuecomment-1656700988)
for some reasons.

Fixes #4602.
2025-07-09 13:20:28 +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
9650753db6 Add configuration hints to existing tooltips 2025-07-09 13:16:42 +02:00
0d4f0e827d Add breaking changes entry for the changed sort order for branches 2025-07-09 13:15:03 +02:00
3575bb9859 Add enum validation for Git.Log.Order and Git.Log.ShowGraph 2025-07-09 13:15:03 +02:00
562a2aaa6b Un-deprecate UserConfig.Git.Log.Order and ShowGraph
And remove them from AppState.
2025-07-09 13:15:03 +02:00
703256e92d Move LocalBranchSortOrder and RemoteBranchSortOrder to user config
At the same time, we change the defaults for both of them to "date" (they were
"recency" and "alphabetical", respectively, before). This is the reason we need
to touch so many integration tests. For some of them I decided to adapt the test
assertions to the changed sort order; for others, I added a SetupConfig step to
set the order back to "recency" so that I don't have to change what the test
does (e.g. how many SelectNextItem() calls are needed to get to a certain
branch).
2025-07-09 13:15:03 +02:00
d79283656d Add missing validation tests 2025-07-09 13:15:03 +02:00
f318e45e9d Move DiffContextSize and RenameSimilarityThreshold to user config 2025-07-09 13:15:03 +02:00
8d7bfd131e Move IgnoreWhitespaceInDiffView to user config
When toggling the value in the UI we simply overwrite the value in UserConfig;
this would be bad if there was ever a chance that we want to write the user
config back to disk, but it is very unlikely that we can do that, because
currently we have no way to tell which parts of the config come from the global
config file and which ones come from a repo-local one.
2025-07-09 13:15:03 +02:00
f3164afa1e Fix keybinding display for local branches sort order to indicate it's a menu 2025-07-09 13:15:03 +02:00
5a5ffb3204 Bump minimum required git version to 2.32 (#4718) 2025-07-09 13:14:24 +02:00