Commit Graph
100 Commits
Author SHA1 Message Date
Stefan HallerandGitHub 9e455f427c Fix rendering of certain emojis (#5116)
This bumps our gocui dependency, which recently learned to render
multi-rune grapheme clusters properly. This fixes rendering of a lot of
emojis such as ️ or 🏴󠁧󠁢󠁥󠁮󠁧󠁿.

Fixes #4854
Fixes #4347
Fixes #3811
Fixes #3711
Fixes #3606
Fixes #3514
Fixes #2702
Fixes #2409
2025-12-23 16:55:47 +01:00
Stefan Haller bb816d7001 Call gocui's SimpleEditor instead of duplicating its code 2025-12-23 16:49:16 +01:00
Stefan Haller 5423e7459c Replace go-runewidth with uniseg 2025-12-23 16:49:16 +01:00
Stefan Haller fec7e9ce61 Bump gocui (and tcell)
and adapt lazygit's client code accordingly.
2025-12-23 16:49:16 +01:00
Stefan HallerandGitHub 32207d25c2 Fix annoying UI stalls after refresh (e.g. background fetch) when the reflog is very long (#5135)
Draw only the visible lines of the reflogs panel, like we do for
commits.

Since the reflog can get very long, this saves some memory but
especially some UI thread lag. In one of my repos I had over 11'000
reflog entries (I guess I should prune them more regularly...), and
rendering them took ~600ms; since this happens on the UI thread, there
was an annoying stall for half a second after every background fetch,
for example (even if the reflog panel is not visible).
2025-12-23 16:23:00 +01:00
Stefan Haller 84be082fb5 Draw only visible part of the reflogs panel
Since the reflog can get very long, this saves some memory but especially some
UI thread lag. In one of my repos I had over 11'000 reflog entries (I guess I
should prune them more regularly...), and rendering them took ~600ms; since this
happens on the UI thread, there was an annoying stall for half a second after
every background fetch, for example.
2025-12-23 16:20:32 +01:00
Stefan Haller f7d4efc59e Rerender visible lines when scrolling by page
This fixes a bug in ListContextTrait.FocusLine whereby the view would go blank
when scrolling by page (using ',' or '.') in views that have
renderOnlyVisibleLines set to true but refreshViewportOnChange set to false.
Currently we don't have any such views; the only ones who use
renderOnlyVisibleLines are commits and subcommits, and they also use
refreshViewportOnChange. However, we are going to add one in the next commit,
and eventually it might be a good idea to convert all our list views to that by
default, and get rid of the renderOnlyVisibleLines flag.
2025-12-23 16:20:32 +01:00
Stefan Haller b4b21f9c65 Fix race condition in HandleRender
Move SetContentLineCount into OverwriteLinesAndClearEverythingElse. Calling it
separately beforehand is not concurrency safe; we need both to happen
when the view's writeMutex is locked.
2025-12-23 16:20:32 +01:00
Stefan HallerandGitHub e1a8327583 Avoid scrolling the selection into view on refresh (#5134)
It is possible to scroll the selection out of view using the mouse
wheel; after doing this, it would sometimes scroll into view by itself
again, for example when a background fetch occurred. In the files panel
this would even happen every 10s with every regular files refresh.

Fix this by adding a scrollIntoView parameter to HandleFocus, which is
false by default, and is only set to true from controllers that change
the selection.

Fixes #5097.
2025-12-23 15:37:18 +01:00
Stefan Haller 478d51c83e When pressing up or down, scroll selection into view if it is outside, even if it didn't change
We have this logic to avoid constantly rerendering the main view when hitting
up-arrow when you are already at the top of the list. That's good, but we do
want to scroll the selection into view if it is outside and you hit up or down,
no matter if it changed.
2025-12-23 15:34:38 +01:00
Stefan Haller efd4298b5e Avoid scrolling the selection into view on refresh
It is possible to scroll the selection out of view using the mouse wheel; after
doing this, it would sometimes scroll into view by itself again, for example
when a background fetch occurred. In the files panel this would even happen
every 10s with every regular files refresh.

Fix this by adding a scrollIntoView parameter to HandleFocus, which is false by
default, and is only set to true from controllers that change the selection.
2025-12-23 15:34:38 +01:00
Stefan Haller 37bc0dfc44 Extract a method for selecting the first branch (and first commit)
We want to do this whenever we switch branches; it wasn't done consistently
though. There are many different ways to switch branches, and only some of these
would reset the selection of all three panels (branches, commits, and reflog).
2025-12-23 15:08:08 +01:00
Stefan HallerandGitHub 74b1255b4b Fix the main view display after reverting a commit (#5138)
After reverting a commit, the main view would show the diff of a commit
that is not the selected one.
2025-12-23 14:59:28 +01:00
Stefan Haller a415d1b529 Fix the main view display after reverting a commit
We move the selection down by the number of commits that were reverted (to keep
the same commits selected). However, this only happens after refreshing, which
has rendered the main view with the wrong commit, so we need to render it again
after moving the selection.

There are many other callers of MoveSelection in LocalCommitsController, but all
of them happen before the refresh. Revert is special because it needs to move
the selection after refreshing, e.g. when reverting the only commit of a branch.
2025-12-23 14:55:58 +01:00
Stefan Haller 0a48f307b1 Add test expectation showing a problem with revert
After the revert, the main view shows the diff of the wrong commit.
2025-12-23 14:48:58 +01:00
Stefan HallerandGitHub cf873b16d9 Prevent many hyperlinks from launching while mouse moving (#5133)
Update our gocui dependency, which brings in the fix that was made
there; see https://github.com/jesseduffield/gocui/pull/86.

(Fix by `Chris McDonnell <c.a.mcdonn@gmail.com>`)
2025-12-22 16:28:42 +01:00
Stefan HallerandChris McDonnell 2189c3b43a Bump gocui
This brings in the fix "Prevent many hyperlinks from launching while mouse
moving".

Co-authored-by: Chris McDonnell <c.a.mcdonn@gmail.com>
2025-12-22 16:22:36 +01:00
Stefan HallerandGitHub e7b69bcf24 Support custom keybindings in custom command menu prompts (#5129)
## Summary
resolves: #3626

This adds support for keybindings on menu options.

### Example Usage:
```yml
customCommands:
  - key: 'e'
    context: 'files'
    command: 'echo {{.Form.Choice | quote}} > result.txt'
    prompts:
      - type: 'menu'
        title: 'Choose an option'
        key: 'Choice'
        options:
          - value: 'foo'
            description: 'FOO'
            key: 'f'
          - value: 'bar'
            description: 'BAR'
            key: 'b'
```

### Please check if the PR fulfills these requirements

* [x] Cheatsheets are up-to-date (run `go generate ./...`)
* [x] Code has been formatted (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting))
* [x] Tests have been added/updated (see
[here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md)
for the integration test guide)
* [x] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [x] If a new UserConfig entry was added, make sure it can be
hot-reloaded (see
[here](https://github.com/jesseduffield/lazygit/blob/master/docs/dev/Codebase_Guide.md#using-userconfig))
* [x] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc
2025-12-22 14:24:29 +01:00
Stefan HallerandGitHub 262e7f4e79 Change keybinding of "keep" item in Merge Conflict menu back to 'k' (#5132)
Now that we can use 'k' as a menu item binding (this was fixed in
#5131), use it for the "keep" entry in the merge menu. I don't think
this will be a problem for people's muscle memory, given that this menu
is not encountered every day; and it's simply the better keybinding.

This reverts commit b32b55201e.
2025-12-22 09:51:26 +01:00
Stefan Haller 6043eb52db Revert "Update resolve conflict using p instead of k"
Now that we can use 'k' as a menu item binding (this was fixed in #5131), use it
for the "keep" entry in the merge menu. I don't think this will be a problem for
people's muscle memory, given that this menu is not encountered every day; and
it's simply the better keybinding.

This reverts commit b32b55201e.
2025-12-22 09:49:04 +01:00
Stefan HallerandGitHub 70fe7bd1b4 Allow using 'j', 'k', 'H', or 'L' as keybindings in custom command menus (#5131)
Previously they would be shown as keybindings in the menu, but they
didn't work because their builtin functionality (select next/prev line,
scroll view left/right) would take precedence.

This will allow us to revert #4934; doing that in a separate PR, see
#5132.
2025-12-22 09:48:38 +01:00
Stefan Haller 344d3866a6 Make menu keybindings take precedence over builtin ones, except for confirm/esc
This makes it possible to use 'j', 'k', 'H' or 'L' as menu item keybindings.
2025-12-22 09:37:06 +01:00
Stefan Haller f996e47199 Rename KeepConfirmKeybindings to KeepConflictingKeybindings
After the change in the previous commit this expresses better what it is about.
2025-12-22 09:37:06 +01:00
Stefan Haller 7e3b24d496 In menus, remove not just the confirm binding, but also esc and up/down
This is not really super important because we are very unlikely to assign a key
such as esc or up/down to a menu item. However, users might do this in a custom
commands menu, and in that case it is important that the builtin keys still
work; or they might remap those builtin commands to other keys, in which case
they might conflict with single-letter keys in normal menus.
2025-12-22 09:37:06 +01:00
Stefan Haller e19544a42b Add a test that demonstrates problems with custom menu keybindings
The test shows two problems: a <down> keybinding is not removed from a menu item
(the 'y' binding is removed though, which is correct), and keybindings such as
'j' and 'H' don't work. We will fix both of these separately in the following
commits.
2025-12-22 09:37:06 +01:00
Stefan HallerandGitHub b7a24c8298 feat: add Codeberg as a supported git hosting service (#5130)
Thank you for an awesome tool. I wanted to add support for codeberg.
Tested locally that opening pull-request works

### PR Description

Codeberg is a Gitea-based git hosting service that uses the same URL
patterns for pull requests and commits but differs on its hostname
2025-12-21 14:13:20 +01:00
Stefan HallerandGitHub 3201695658 feat: add keys for command log menu items (#5096) 2025-12-14 17:14:50 +01:00
Stefan HallerandGitHub 8651c46e14 Fix small issues with the Breaking Changes texts (#5114) 2025-12-11 21:13:30 +01:00
Stefan Haller 46c095cc29 Add a missing quote 2025-12-11 21:10:11 +01:00
Stefan Haller 9aa268c1f4 Cleanup: use spaces instead of tab 2025-12-11 21:09:57 +01:00
Stefan HallerandGitHub 6600adf671 Remove confirmation for opening the merge tool (#5094)
The confirmation used to make sense back when the Open MergeTool command
was its own top-level command; however, that command was changed in
#4889 to open a menu instead, and Open MergeTool is now just a submenu
entry in that menu, so it no longer needs a confirmation.

Fixes #5093.
2025-12-08 09:48:58 +01:00
Stefan Haller f6cba966d0 Remove confirmation for opening the merge tool
The confirmation used to make sense back when the Open MergeTool command was its
own top-level command; however, that command was changed in 703f053a7e to open a
menu instead, and Open MergeTool is now just a submenu entry in that menu, so it
no longer needs a confirmation.
2025-12-07 20:55:25 +01:00
Stefan HallerandGitHub 17d03ec8cb Update docs and schema for release (#5091) 2025-12-06 13:58:23 +01:00
Stefan Haller da4494fb06 Update docs and schema for release 2025-12-06 13:49:02 +01:00
Stefan HallerandGitHub 8ced11b5ae README.md: Update Sponsors (#5055)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-12-06 13:48:26 +01:00
Stefan HallerandGitHub 17c6a895b4 Update translations from Crowdin (#5090) 2025-12-06 13:30:13 +01:00
Stefan Haller 6fbf64b70e Update translations from Crowdin 2025-12-06 13:28:19 +01:00
Stefan HallerandGitHub cc96d8cede Fix to support creating MRs for repositories cloned with SSH alias (#5082)
### PR Description

Use case: some repositories are cloned with a full SSH alias (without a
user). E.g. in `.ssh/config` you have

```
Host gitlab
    HostName gitlab.com
    User git
    IdentityFile ...
```

and then you clone with `git clone gitlab:foo/bar`

According to the docs, you can add a service to `config.yaml` and it
should work:

```yaml
services:
  gitlab: 'gitlab:gitlab.com'
```

But currently it doesn't because lazygit expects all remote URLs to have
a user. This can be fixed by the user by changing the URL to e.g.
`git@gitlab:foo/bar`, but it breaks the user flow and is quite
unexpected.

This PR changes `defaultUrlRegexStrings` and makes the `user@` part of
the remote URL optional. Fixes the issue for Github and Gitlab which use
the default regexes.
2025-12-06 11:58:44 +01:00
Stefan HallerandGitHub 0fc8cb35a8 chore: fix function name in comment (#4481) 2025-12-06 11:45:51 +01:00
Stefan HallerandGitHub 06426b2107 refactor: use strings.Builder and strings.Repeat to simplify code (#5068)
### PR Description

strings.Builder has fewer memory allocations and better performance.
More info: [golang/go#75190](https://github.com/golang/go/issues/75190)
2025-12-03 18:39:11 +01:00
Stefan HallerandGitHub 8396747cf1 Band-aid fix for rare crashes when refreshing files (#5074)
Users have filed issues with crash reports that seem to indicate that
the FileTreeViewModel gets swapped out (by a refresh) while a call to
itemsSelected is in progress, iterating over the previous items. Guard
against this by locking the mutex that we already have for this for the
duration of the call.

I don't have a good way of testing whether the fix helps, because the
crashes only occurred very infrequently. Let's just see if the crash
reports stop coming in after we ship this.

Note also that this is only the minimal fix for the crashes that were
reported. Theoretically, the same problem could happen for a key handler
itself, but we never saw reports about that, so we don't bother doing
anything about that yet.

Note also that long-term I envision a different solution to this class
of problems (discussed in
https://github.com/jesseduffield/lazygit/issues/2974), that's why I want
to avoid locking mutexes more than necessary now.

Fixes #3646 
Fixes #4154
Fixes #4301
Fixes #5070
2025-12-03 08:10:13 +01:00
Stefan Haller d274474c61 Band-aid fix for rare crashes when refreshing files
Users have filed issues with crash reports that seem to indicate that the
FileTreeViewModel gets swapped out (by a refresh) while a call to itemsSelected
is in progress, iterating over the previous items. Guard against this by locking
the mutex that we already have for this for the duration of the call.

I don't have a good way of testing whether the fix helps, because the crashes
only occurred very infrequently. Let's just see if the crash reports stop coming
in after we ship this.

Note also that this is only the minimal fix for the crashes that were reported.
Theoretically, the same problem could happen for a key handler itself, but we
never saw reports about that, so we don't bother doing anything about that yet.

Note also that long-term I envision a different solution to this class of
problems (discussed in https://github.com/jesseduffield/lazygit/issues/2974),
that's why I want to avoid locking mutexes more than necessary now.
2025-12-03 08:08:21 +01:00
Stefan HallerandGitHub d1d2bb23b6 Show fixup base commits in correct order in ctrl-f error message (#5073)
If the ctrl-f command ("Find base commit for fixup") finds multiple
candidates, it lists them all in an error message. Previously they were
listed in random order in the error message, which can be confusing;
it's nicer to see them in the same order in which they appear in the
commit log.

Fixes #5071.
2025-11-30 14:08:22 +01:00
Stefan Haller 26453b26cf Remove unused function GetHashesAndCommitMessagesFirstLine 2025-11-30 14:06:31 +01:00
Stefan Haller e2b3601c57 Fix order of fixup base commits shown in ctrl-f error message 2025-11-30 14:06:31 +01:00
Stefan Haller c16b4b1d2e Make find_base_commit_for_fixup tests more specific
We want to test the order in which the commits are listed in the error message.
For one of the tests the order is already as we want it, but for the other it's
not (we want them to show up in log order). We'll fix this in the next commit.
2025-11-30 14:06:31 +01:00
Stefan HallerandGitHub 28cd1c2df4 Don't use "HEADLESS" environment variable for running tests (#5064)
It is a bit generic, it seems that users sometimes set it for other
reasons (see
https://github.com/jesseduffield/lazygit/issues/5030#issuecomment-3541000735),
and then they are confused why they don't see anything. Use a more
specific name instead.
2025-11-28 12:09:17 +01:00
Stefan Haller 9334bf0333 Don't use "HEADLESS" environment variable for running tests
It is a bit generic, it seems that users sometimes set it for other reasons, and
then they are confused why they don't see anything. Use a more specific name
instead.
2025-11-28 12:06:42 +01:00
Stefan HallerandGitHub e3ea666352 Fix deleting a remote tag when a remote branch with the same name exists, or vice versa (#5075)
Nothing to add to the PR title here.

Fixes #5072.
2025-11-28 12:06:03 +01:00
Stefan Haller 11a6a73be5 Fix deleting a remote tag when a remote branch with the same name exists 2025-11-27 19:52:18 +01:00
Stefan Haller 7809823064 Fix deleting a remote branch when a remote tag with the same name exists 2025-11-27 19:51:24 +01:00
Stefan Haller 4d4b143cc7 Add tests demonstrating the problem
Trying to delete a remote tag when a remote branch with the same name exists
results in an error, and vice versa.
2025-11-27 19:51:13 +01:00
Stefan Haller 19a4454599 Cleanup: remove unnecessary keypress
Seems to be a copy/paste error from another test.
2025-11-27 19:32:22 +01:00
Stefan HallerandGitHub b57be9ebe4 Fix and speed up the file list for the "Enter path to filter by" feature (#5056)
The file suggestions list that appears when you choose "Enter path to
filter by" from the Filtering menu was previously implemented by walking
the file system to collect all files, and then filter out the ones that
are git-ignored. This approach had several problems:
- for certain .gitignore configurations there was a bug in the code that
filters out ignored files, causing the list to be empty. See
https://github.com/jesseduffield/lazygit/issues/2642#issuecomment-3554117172
for details.
- the list included files from submodules. While at first glance this
might sound useful, it doesn't work: choosing a file from the list shows
an empty log. Lazygit would have to switch to the submodule first to
show the log, which would be unexpected in the context of the Filtering
dialog, so it's better to not show these files, and require the user to
enter a submodule explicitly before they can filter on a file in it.
- it was rather slow.

This PR improves all these by using a call to `git ls-files` to list the
repositories files.

Here are some rough hand-timed measurements (from opening the Filtering
dialog until the file list shows) for various repos:

|                             | before | after          |
|:--------------------------- | ------:| -------------- |
| lazygit (3'200 files)       |    ~1s | not measurable |
| my work repo (90'000 files) |     7s | <1s            |
| llvm (150'000 files)        |     5s | ~1s            |

Fixes #2642
2025-11-21 07:59:58 +01:00
Stefan Haller b06c2bb025 Remove the 'minimal' dependency which we no longer need 2025-11-21 07:57:56 +01:00
Stefan Haller 1c1676a5d9 Use git ls-files to list all file suggestions 2025-11-21 07:57:56 +01:00
Stefan HallerandGitHub 9d24963ea0 Bump golang.org/x/crypto from 0.37.0 to 0.45.0 (#5054)
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from
0.37.0 to 0.45.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="https://github.com/golang/crypto/commit/4e0068c0098be10d7025c99ab7c50ce454c1f0f9"><code>4e0068c</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/crypto/commit/e79546e28b85ea53dd37afe1c4102746ef553b9c"><code>e79546e</code></a>
ssh: curb GSSAPI DoS risk by limiting number of specified OIDs</li>
<li><a
href="https://github.com/golang/crypto/commit/f91f7a7c31bf90b39c1de895ad116a2bacc88748"><code>f91f7a7</code></a>
ssh/agent: prevent panic on malformed constraint</li>
<li><a
href="https://github.com/golang/crypto/commit/2df4153a0311bdfea44376e0eb6ef2faefb0275b"><code>2df4153</code></a>
acme/autocert: let automatic renewal work with short lifetime certs</li>
<li><a
href="https://github.com/golang/crypto/commit/bcf6a849efcf4702fa5172cb0998b46c3da1e989"><code>bcf6a84</code></a>
acme: pass context to request</li>
<li><a
href="https://github.com/golang/crypto/commit/b4f2b62076abeee4e43fb59544dac565715fbf1e"><code>b4f2b62</code></a>
ssh: fix error message on unsupported cipher</li>
<li><a
href="https://github.com/golang/crypto/commit/79ec3a51fcc7fbd2691d56155d578225ccc542e2"><code>79ec3a5</code></a>
ssh: allow to bind to a hostname in remote forwarding</li>
<li><a
href="https://github.com/golang/crypto/commit/122a78f140d9d3303ed3261bc374bbbca149140f"><code>122a78f</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="https://github.com/golang/crypto/commit/c0531f9c34514ad5c5551e2d6ce569ca673a8afd"><code>c0531f9</code></a>
all: eliminate vet diagnostics</li>
<li><a
href="https://github.com/golang/crypto/commit/0997000b45e3a40598272081bcad03ffd21b8adb"><code>0997000</code></a>
all: fix some comments</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/crypto/compare/v0.37.0...v0.45.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/crypto&package-manager=go_modules&previous-version=0.37.0&new-version=0.45.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/jesseduffield/lazygit/network/alerts).

</details>
2025-11-20 08:26:55 +01:00
Stefan HallerandGitHub 11c7203db6 Switch to branches view when checking out a commit (#5048)
We move the code to push the branches context into CheckoutRef, this way
it works consistently no matter where we call it from. Previously,
checking out remote branches or tags would switch to the branches view,
but checking out a commit did not.

Note that it now also takes effect for undoing or redoing a checkout,
which may be a bit questionable; but I still think it makes sense for
this, too.
2025-11-16 21:28:22 +01:00
Stefan Haller 221e025ee6 Switch to branches view when checking out a commit
We move the code to push the branches context into CheckoutRef, this way it
works consistently no matter where we call it from. Previously, checking out
remote branches or tags would switch to the branches view, but checking out a
commit did not.

Note that it now also takes effect for undoing or redoing a checkout, which may
be a bit questionable; but I still think it makes sense for this, too.
2025-11-16 21:23:40 +01:00
Stefan Haller e3a09eacd1 Cleanup: reformat
We usually put Lines() on a line by itself, and it makes the diff of the next
commit much easier to read.
2025-11-16 19:10:21 +01:00
Stefan HallerandGitHub 9f930eee06 Trigger immediate background fetch when switching repos (#5047)
If background fetching is on (which it is by default), we usually run
the first background fetch right after opening lazygit, which is nice
because it immediately fetches all the stuff that's new. However, when
switching to a different repo from within lazygit (either with the
recent repos menu or by going into or out of a submodule) we didn't do
that, and you'd have to wait for the next regular background fetch to
come along. I'm finding myself pressing `f` in the Files panel to
manually fetch after entering a submodule, and I shouldn't have to do
that.

This PR makes it so that when you switch repos, we trigger a background
fetch immediately (unless the last one for this repo was less than the
auto-fetch interval ago, in which case it's unnecessary).
2025-11-16 17:37:12 +01:00
Stefan Haller 2af56de5d2 Trigger background fetch on repo switch only if enough time has passed since the last one 2025-11-16 17:32:37 +01:00
Stefan Haller d45f27b6ee Add methods for converting RefresherConfig times to time.Durations 2025-11-16 17:32:37 +01:00
Stefan Haller 472b964da3 Cleanup: don't pass refreshInterval to startBackgroundFilesRefresh
It has access to UserConfig, so it can easily get it from there. This is how we
do it for startBackgroundFetch too, so be consistent.
2025-11-16 17:32:37 +01:00
Stefan Haller aff6b642ea Trigger immediate background fetch when switching repos 2025-11-16 17:32:37 +01:00
Stefan Haller 8f4bf49aff Cleanup: remove unused field 2025-11-16 17:32:37 +01:00
Stefan HallerandGitHub ce7622262f feat: add fork remote command (#4831)
The command allows you to quickly add a fork remote by replacing the
owner in the origin URL and optionally check out a branch from new
remote.

Examples:

* given url: `https://github.com/jesseduffield/lazygit.git`
  and username: `karolzwolak`
  
adds a new remote with url: `https://github.com/karolzwolak/lazygit.git`
  
  
* given url: `https://github.com/jesseduffield/lazygit.git`
  and username: `karolzwolak:add-fork-remote-command`
  
adds a new remote with url: `https://github.com/karolzwolak/lazygit.git`
  and then checks out it's branch `add-fork-remote-command`
2025-11-16 17:28:11 +01:00
Stefan HallerandGitHub ba632d4064 Update table of contents in README.md (#5045)
### PR Description
Adding and fixing some links in the table of contents of the README.
2025-11-16 09:10:54 +01:00
Stefan HallerandGitHub 58d2ffa1d6 Suppress output from background fetch (unless there were errors) (#5044)
The output from background fetching is noisy and pollutes the command
log. Don't show it by default, unless there were errors, in which case
it is important to see e.g. which fork was deleted.
2025-11-15 18:32:43 +01:00
Stefan Haller f8a48b61fc Suppress output from background fetch
However, show it when there was an error. This is important for the case that a
fork that you have as a remote was deleted, in which case the command log is the
only way to get notified about that.
2025-11-15 18:27:18 +01:00
Stefan Haller eb91a43d58 Test properties of cmdObj for Push 2025-11-15 18:25:52 +01:00
Stefan Haller 9272276247 Don't log the GetDiff command
This is used for internal purposes and shouldn't pollute the command log.
2025-11-15 18:15:24 +01:00
Stefan HallerandGitHub 933573fd94 Don't allow empty input in most prompts (#5043)
Most of our prompts don't (shouldn't) allow empty input, but most
callers didn't check, and would run into cryptic errors when the user
pressed enter at an empty prompt (e.g. when creating a new branch). Now
we simply don't allow hitting enter in this case, and show an error
toast instead.

This behavior is opt-out, because there are a few cases where empty
input is supported (e.g. creating a stash).
2025-11-15 15:41:54 +01:00
Stefan Haller 95e5ed6f47 Remove TrimSpace calls that are no longer needed
The prompt code takes care of this now.
2025-11-15 15:38:24 +01:00
Stefan Haller 7c126cd2fc Strip leading/trailing whitespace from prompt input
This doesn't really solve a pressing problem, because I guess it's unlikely that
users add spaces at the beginning or end of what they type into a prompt; but it
could happen, and in this case we almost always want to strip it. Just adding
this here for completeness while I was working on this code.

The only exception is the input prompt of custom commands, because who knows
what users want to use that input for in their custom command.
2025-11-15 15:38:24 +01:00
Stefan Haller d7e733cd56 Remove now unnecessary check for empty string
As of the previous commit, branchName can no longer be empty, so no need to
handle this.
2025-11-15 15:38:24 +01:00
Stefan Haller b3435bd59c Add AllowEmptyInput flag to PromptOpts
Most of our prompts don't (shouldn't) allow empty input, but most callers didn't
check, and would run into cryptic errors when the user pressed enter at an empty
prompt (e.g. when creating a new branch). Now we simply don't allow hitting
enter in this case, and show an error toast instead.

This behavior is opt-out, because there are a few cases where empty input is
supported (e.g. creating a stash).
2025-11-15 15:36:43 +01:00
Stefan Haller a7bc1012b9 Cleanup: fix incorrect comment
The comment was apparently copy/pasted from above; the branch name cannot be
blank in this case.
2025-11-15 14:46:19 +01:00
Stefan Haller 48330141bd Cleanup: put the IsPasting logic in the right place
Previously it was used both for the Confirm handler and the Cancel handler, as
well as for the Confirm handler of confirmation popups (not prompts). There was
no other way to do it given how wrappedConfirmationFunction was shared between
all these; but now there is. The logic is really only needed for the Confirm
handler of prompts.

This doesn't fix anything, it just makes things clearer.
2025-11-15 14:13:24 +01:00
Stefan Haller 8d8cf42786 Refactor: extract body of wrappedConfirmationFunction into a helper function
And call this new helper function from both wrappedConfirmationFunction and
wrappedPromptConfirmationFunction; this gives us more flexibility to do
different things in each of those.
2025-11-15 14:07:36 +01:00
Stefan HallerandGitHub 3d5b22f804 Modernize all codes (#5036)
go run
golang.org/x/tools/gopls/internal/analysis/modernize/cmd/modernize@latest
-fix -test ./...
2025-11-15 10:48:35 +01:00
Stefan HallerandGitHub a7126d5456 Allow using SelectedSubmodule in CustomCommands (#5015)
This PR allows the use of `{{ SelectedSubmodule.Path }}`, `{{
SelectedSubmodule.Name }}` and `{{ SelectedSubmodule.Url }}` in custom
commands.
2025-11-12 09:00:22 +01:00
Stefan HallerandGitHub dd04cd8f58 Keep config and schema unchanged during a release (#5010)
Some of our documentation is auto-generated from the source code (the
defaults section in Config.md, and the keybinding cheat sheets), and so
is the JSON schema for the config file. We have a check running on CI
that verifies that when the source code changes (e.g. a new config
option is added), those files are properly regenerated, to make sure
they are always up to date with the latest version of the source code.

This causes a problem when people look at the documentation for a newly
added config option and wonder why it doesn't work in the lazygit
version they are using. Lots of issues were filed where people report
this as a bug, and we have to patiently explain to them that the
documentation describes a feature that hasn't been released yet. A
similar problem occurs when we rename a config option (as has recently
happened with the 'paging' config, which was renamed to 'pagers' in
#4953), in which case the user's editor (if it supports JSON validation
against the jsonschema store) starts to complain about the old config,
even though it still works, and the new one doesn't yet.

To solve this, keep the documentation and the JSON schema unchanged for
the lifetime of a release; make those continuous changes in a separate
copy of those folders, and only copy the files back to the real location
right before we make a release. To facilitate this, we add a script to
conveniently create a PR for copying the files back, and add a check to
the release workflow to abort with an error if this was forgotten.

Note that we only use this approach in order to solve the problem with
the auto-generated files; this has a consequence for making changes to
the other, non-auto-generated parts of the docs. For example, when
fixing a spelling error, rewording a paragraph to explain it better, or
adding an entirely new file, those changes will now have to be made in
docs-master, which means:
1. if we forget this and make the change in `docs` accidentally, it will
be reverted with the next release.
2. if we do remember to make the change in docs-master, it will take
until the next release for it to be visible to users.

We can mitigate 2. by making the identical change in both places, but I
think we should first wait and see how often it happens, and whether it
is actually a problem.
2025-11-12 08:47:11 +01:00
Stefan Haller 6ab40df429 Add a check to the release workflow to abort if docs or schema are not up to date
Of course it would be cooler if the workflow could create the PR and merge it if
necessary, but this will have to do for now.
2025-11-12 08:44:56 +01:00
Stefan Haller 7ce1501f3e Add a script for copying the docs and schema over for release
This needs to be run immediately before creating a release.

We could go further here and use gh to create the PR, but since I'm usually
logged in with my work account to gh, this won't help me. The git push command
prints the URL to create the PR, so it's a simple matter of command-clicking it,
which is good enough for me.
2025-11-12 08:44:56 +01:00
Stefan Haller 7627da594d Update generators to change the files in the -master directories 2025-11-12 08:44:56 +01:00
Stefan Haller d5677318ab Make copies of the docs and schema folders
The plan is to keep the original docs and schema folders unchanged for the
duration of a release; we'll only continuously update the -master copies. Right
before a new release we will copy them over.
2025-11-12 08:44:56 +01:00
Stefan Haller e3a1fe514c Make link relative
This way it will also work when we make a copy of the entire docs folder.
2025-11-12 08:44:56 +01:00
Stefan HallerandGitHub 42e4232e56 Keep cursor at top/bottom when navigating by page (#5019)
When pressing '.' (next page) or ',' (previous page), the selection now
stays at the bottom or top of the viewport respectively, instead of
being centered which caused items to scroll off. (If the selection is
not already on the last/first line of the view, '.'/',' moves it there
without scrolling.)

This implements a special case for page navigation as suggested by the
maintainer in issue #5017, keeping the cursor position consistent with
user expectations for page-based navigation.

Fixes #5017
2025-11-09 19:43:48 +01:00
Stefan Haller 2576258ba3 Cleanup: remove unnecessary code
The method is only called from keybinding handlers, so the view must be focused
already, otherwise the binding wouldn't have been dispatched to it.
2025-11-09 19:37:38 +01:00
Stefan HallerandGitHub 9c0cbd83c7 Open pull requests in browser with extra leading slashes removed (#5018)
### PR Description

This allows for having extra slashes in git URLs. Especially in
submodules. Those may be used to avoid warnings with older bitbake
fetcher implementations in yocto. Which warns about relative urls when
not having a slash in git urls.

- git@bitbucket.org:project/repo.git -> generates a warning in bitbake,
which is annoying.
- git@bitbucket.org:/project/repo.git -> does not generate a warning in
bitbake.

But when trying to open a PR from lazygit with an url like
git@bitbucket.org:/project/repo.git leads to
https://bitbucket.org//project/repo being opened and one has to stare at
a blank page unless one removes the extra / manualy.

This PR updates the regex used for matching git url fragments in a way,
that the extra `/` is ignored.
2025-11-07 16:23:08 +01:00
Stefan HallerandGitHub 1d17507795 Add a "Commit history" section to CONTRIBUTING.md (#5022)
I see too many PRs with terrible commit histories; maybe this will help
a bit with that.
2025-11-07 13:20:50 +01:00
Stefan Haller 6ff18bbc36 Add a "Commit history" section to CONTRIBUTING.md
I see too many PRs with terrible commit histories; maybe this will help a bit
with that.
2025-11-07 13:12:09 +01:00
Stefan Haller 6aea67ca50 Cleanup: format markdown
I want to be able to press Command-S in VS Code and not have it reformat code
that I didn't edit.
2025-11-07 12:28:15 +01:00
Stefan HallerandGitHub aa2bdb0091 README.md: Update Sponsors (#4946)
Automated changes by
[create-pull-request](https://github.com/peter-evans/create-pull-request)
GitHub action
2025-11-02 07:52:00 +01:00
Stefan HallerandGitHub 80223c7fbb Fix keybinding cheatsheets with regard to pipe characters in key or description (#5007)
The "Cycle pagers" command wasn't rendered correctly, because it's bound
to '|' by default, but this was taked as a table column delimiter. Fix
this by escaping the pipe character.

A similar thing could happen for the description or tooltip (and did in
fact, for a tooltip in the russion translation), so escape those too
just to be sure.
2025-11-01 09:56:57 +01:00
Stefan Haller ff0a16f809 Fix keybinding cheatsheets with regard to pipe characters in key or description
The "Cycle pagers" command wasn't rendered correctly, because it's bound to '|'
by default, but this was taked as a table column delimiter. Fix this by escaping
the pipe character.

A similar thing could happen for the description or tooltip (and did in fact,
for a tooltip in the russion translation), so escape those too just to be sure.
2025-11-01 09:54:32 +01:00
Stefan HallerandGitHub 48c1db6fe4 Fix fixup's false filename detection in hunks containing dashed lines (#5004)
### PR Description

The existing diff parser incorrectly treated subsequent lines beginning
with `---` as filename headers while processing hunks. This caused
corruption when dashed lines appeared within diffs themselves.

Restrict filename detection to only occur between hunks.

This repository https://github.com/abobov/lazygit-fixup-issue
demonstrates the issue:

- clone repository
- run `git reset --soft HEAD~`
- try `<c-f>` Find base commit for fixup 
- `fatal: no such path ...` error
2025-11-01 09:42:45 +01:00
Stefan HallerandGitHub f4920e8efa Use a PTY when using external diff command from git config (#4983)
### PR Description

I hit the same issue as
https://github.com/jesseduffield/lazygit/issues/3119 when setting
`useExtDiffGitConfig` to true and using `difftastic` side-by-side
comparison in my git config.

The same fix in https://github.com/jesseduffield/lazygit/pull/3120 needs
to be applied for the newer config option.
2025-11-01 09:35:45 +01:00
Stefan HallerandGitHub 6f0f1e7995 Update translations from Crowdin (#5005) 2025-10-31 19:58:37 +01:00