Commit graph

5739 commits

Author SHA1 Message Date
Yaroslav Halchenko
1e8eb72b2f Do not git ignore .codespellrc
Signed-off-by: Yaroslav Halchenko <debian@onerussian.com>
2024-08-27 18:03:00 +02:00
Stefan Haller
18935bf7f0
Fix linter warnings (#3854)
- **PR Description**

Fix some linter warnings that I keep getting locally because I'm running
a newer version of golangci-lint than the pinned version we use on CI.

Also, update the pinned version in CI to 1.60 so that we are in sync
again.

Finally, upgrade the golangci-lint-action version to the latest,
although I'm not sure what difference this makes. The linting step runs
faster now, maybe because of better caching -- I noticed that
previously, loading and saving the cache took a very long time, which
often made the lint step the slowest of all.
2024-08-27 13:12:40 +02:00
Stefan Haller
457c4c248d Upgrade golangci-lint-action to latest version 2024-08-27 10:33:06 +02:00
Stefan Haller
8c553dcde9 Upgrade golang-ci to 1.60 2024-08-27 10:33:06 +02:00
Stefan Haller
a709caf138 Remove error return value from functions that always return nil 2024-08-27 10:33:06 +02:00
Stefan Haller
8dea2dab88 Ignore return values of fmt.Scanln 2024-08-27 10:33:06 +02:00
Stefan Haller
63aa32c521 Remove "double" formatting 2024-08-27 10:33:06 +02:00
Stefan Haller
24841f22f1 Use print instead of printf when there are no arguments 2024-08-27 10:33:06 +02:00
Stefan Haller
d712c2f199 Use format arguments instead of concatenating strings
That's what they are for.
2024-08-27 10:33:06 +02:00
Stefan Haller
4525216d26
Fix cancelled autostash resulting in stuck inline status (#3860)
- **PR Description**

When switching branches, there is a "Checking out" inline status
displayed next to the branch (but only sometimes? I think if the action
completes too quickly there is no status). If it does get displayed and
the checkout results in an autostash confirmation prompt, pressing
escape to cancel the action will cancel the checkout and close the
prompt. However, the inline status will still be displayed next to the
branch and doesn't go away by itself. Performing a manual UI refresh
(`R`) fixes the state.

If the prompt was confirmed instead, then this issue would not happen.

Reproduction:
```bash
git init
echo -e "a\n\nb" > file
git add .
git commit -m "add file"
echo -e "a\n\nc" > file
git add .
git commit -m "edit last line"
git checkout -b dev HEAD~
echo -e "b\n\nb" > file
lazygit
```

Switch to the other branch in the branches panel and press escape on the
prompt. The "Checking out" inline status should be stuck.
2024-08-27 10:30:31 +02:00
Brandon
ae61da7485 Fix cancelled autostash resulting in stuck inline status 2024-08-27 10:28:22 +02:00
Stefan Haller
fb9f6153fc
Add missing closing quote in pager docs (#3864)
- **PR Description**

Add missing closing quote in pager docs.
2024-08-27 10:22:47 +02:00
Stefan Haller
a0c808842b Add missing closing quote 2024-08-27 10:16:53 +02:00
Stefan Haller
8a8490d97d
Underline hyperlinks only on mouse hover (#3856)
- **PR Description**

Followup to #3825: we decided there that we don't want to underline
links in delta diffs by default, but only on mouse hover. This PR does
that; it makes it possible to decide per view whether links should be
underlined always, or only on hover. We set this to only on hover for
the main views, so that links in diffs are not underlined (also affects
the status view though), but all other links we want to underline always
for better discoverability.
2024-08-24 17:49:10 +02:00
Stefan Haller
68c7f9840a Set main views to underline hyperlinks only on mouse hover
Note that this doesn't only affect the diff views, which are the ones where we
want this, but also the status view, where the plan was to keep them underlined
always for better discoverability. We could make this configurable dynamically
(by adding another flag to ViewUpdateOpts), but actually I think it's fine this
way.
2024-08-24 17:45:54 +02:00
Stefan Haller
8d37f48744 Bump gocui 2024-08-24 17:45:51 +02:00
Stefan Haller
37f32755b5
Fix rendering regression introduced in #3839 (#3855)
- **PR Description**

Fix broken rendering introduced in #3839: the status view would often render only partially.
2024-08-24 11:51:53 +02:00
Stefan Haller
5380fe2483 Fix rendering regression introduced in #3839 2024-08-24 11:46:53 +02:00
Stefan Haller
8e71df3e53
Fix loading customCommands from per-repo config file (#3835)
- **PR Description**

Any newly loaded custom command coming from the per-repo config file should add
to the global ones (or override an existing one in the global one), rather than
replace all global ones.
2024-08-24 11:04:56 +02:00
Stefan Haller
30f43a245b Fix loading customCommands from per-repo config file
Any newly loaded custom command coming from the per-repo config file should add
to the global ones (or override an existing one in the global one), rather than
replace all global ones.

We can achieve this by simply prepending the newly loaded commands to the
existing ones. We don't have to take care of removing duplicate key assignments;
it is already possible to add two custom commands with the same key to the
global config file, the first one wins.
2024-08-24 11:01:25 +02:00
Stefan Haller
283ed29f10 Add a test that shows how per-repo config file replaces customCommands
We want to add to the global customCommands instead of replacing them.
2024-08-24 11:01:25 +02:00
Stefan Haller
ccd39bb8ae Fix wrong test assertion text
If a `t.FileSystem().FileContent("file.txt", Equals("bla"))` assertion fails
because the file doesn't exist, the error would say

   Expected path 'file.txt' to not exist, but it does

which is very confusing.
2024-08-24 11:01:25 +02:00
Stefan Haller
db40653202
Allow using </> and ,/. in sticky range select mode in patch explorer (#3837)
- **PR Description**

Don't cancel sticky range select when pressing `<`/`>`, `,`/`.` in the
patch explorer view. This was already working correctly in list views.

Fixes #3823.
2024-08-24 10:59:48 +02:00
Stefan Haller
d3940729eb Allow using </> and ,/. in sticky range select mode in patch explorer
They still cancel hunk selection mode, setting it to line selection mode, but if
range selection mode is on, we keep it on.
2024-08-24 10:56:20 +02:00
Stefan Haller
56a6ee6afb Cleanup: move SetLineSelectMode into AdjustSelectedLineIdx 2024-08-24 10:56:20 +02:00
Stefan Haller
a37a3fc4a1
Fix crash when filtering commits (#3838)
- **PR Description**

First we fix the crash reported in #3812 (see there for reproduction
recipe), and then we add a more general fix for avoiding crashes in
similar situations that we don't know about yet.

I'm not really happy with the brittleness of all this (the
interdependency between rendering and updating search results, that is),
but I haven't found a good way to untangle this yet.

Fixes #3812.
2024-08-24 10:55:12 +02:00
Stefan Haller
af87cd1dd6 Don't return model search results for commits when we don't have columnPositions
We fixed one specific scenario where this happened ealier in this branch, but in
case there are more that we don't know about yet, at least make sure we don't
crash.
2024-08-24 10:51:25 +02:00
Stefan Haller
e675025411 Return nil columnPositions when not rendering anything
... instead of returning a slice with a single [0] element. This makes it easier
to check whether we have columnPositions.
2024-08-24 10:51:25 +02:00
Stefan Haller
c3d5798c6c Fix early exit condition
I don't know what this condition is supposed to guard against, or whether we
really need it (it was added in 06ca71e955, and the commit message of that
commit only says "fix bug"). But if we do need it, then it seems that `>=` is
more correct than `>`.
2024-08-24 10:51:25 +02:00
Stefan Haller
15d17e16dd Call ReApplySearch after layout
This fixes a possible crash when exiting filter mode in the commits panel.
2024-08-24 10:51:25 +02:00
Stefan Haller
926061557b Make searching available in the filtered commits list
It is already possible to search a filtered list by searching first, and then
enabling a filter, so I found it inconsistent to not allow searching when you
are already filtering. One reason for not allowing this might be that the search
status (on the left) hides the filter status (on the right), but if we think
that's enough reason to not allow both at the same time, then we should cancel a
search when we enter filtering.
2024-08-24 10:51:25 +02:00
Stefan Haller
8522337f32
Scroll views up if needed to show all their content (#3839)
- **PR Description**

There are many situations where this can arise. Some examples are:
- the terminal window is small, and you are showing a view that shows more
content than fits into the view port, and the view is scrolled all the way
down; now you resize the terminal window to a taller size. Previously, the
scroll position of the view would stay the same, so it would add blank space
at the bottom; now it will scroll to fill that blank space with content
- expandFocusedSidePanel is on, you go to the bottom of a list view, now switch
to a different panel, then scroll that (now unfocused) panel all the way down
with the scroll wheel; now you focus that panel again. It becomes larger
because of the accordion behavior, but would show blank space at the
bottom.

And probably others that I can't remember right now. I only remember that I
always found it confusing to look at a view that had blank space at the bottom
even though it had more content to scroll into view.
2024-08-24 10:50:50 +02:00
Stefan Haller
6114f69ee5 Scroll views up if needed to show all their content
There are many situations where this can arise. Some examples are:
- the terminal window is small, and you are showing a view that shows more
  content than fits into the view port, and the view is scrolled all the way
  down; now you resize the terminal window to a taller size. Previously, the
  scroll position of the view would stay the same, so it would add blank space
  at the bottom; now it will scroll to fill that blank space with content
- expandFocusedSidePanel is on, you go to the bottom of a list view, now switch
  to a different panel, then scroll that (now unfocused) panel all the way down
  with the scroll wheel; now you focus that panel again. It becomes larger
  because of the accordion behavior, but would show blank space at the bottom.

And probably others that I can't remember right now. I only remember that I
always found it confusing to look at a view that had blank space at the bottom
even though it had more content to scroll into view.
2024-08-24 10:47:27 +02:00
Stefan Haller
0aa351443f Bump gocui 2024-08-24 10:47:25 +02:00
Stefan Haller
c28ecabfd8
Support hyperlinks from pagers (#3825)
- **PR Description**

Allows to use `delta --hyperlinks` as a pager, which turns line numbers
in the diff into clickable links that take you to the respective file.
For VS Code users, I recommend to combine this with
`--hyperlinks-file-link-format="vscode://file/{path}:{line}"`
so that it jumps to the right line.

In addition, I added a few commits that replaces our old, manual ad-hoc
handling of links in various places (status view, confirmation panels,
information view) with the new hyperlinks feature, which cleans up the
code a bit.

Fixes #3817.
2024-08-24 10:39:41 +02:00
Stefan Haller
bbd779b437 Use our new hyperlink support in the information view 2024-08-24 10:36:01 +02:00
Stefan Haller
b411897a5a Fix Decolorise to also strip hyperlinks
This is needed so that the information view is correctly aligned when we add
hyperlinks to it.
2024-08-24 10:36:01 +02:00
Stefan Haller
fb97c30080 Remove now unused function handleGenericClick 2024-08-24 10:36:01 +02:00
Stefan Haller
61b59837bb Use our new hyperlink support in confirmations 2024-08-24 10:36:01 +02:00
Stefan Haller
e65c0a9d5e Use our new hyperlink support in the status panel 2024-08-24 10:36:01 +02:00
Stefan Haller
3f7674a2e9 Add function to render a hyperlink
It might seem cleaner to integrate this into the text style system, so that you
could say `ts := ts.Url("some link")` and then `ts.Sprint("my text")`. However,
this would require adding a new field to TextStyle, which I didn't want to do.
2024-08-24 10:36:01 +02:00
Stefan Haller
fb81fc6057 Add documentation about delta --hyperlinks 2024-08-24 10:36:01 +02:00
Stefan Haller
e1acb6a547 Set an openHyperlink function on gocui 2024-08-24 10:36:01 +02:00
Stefan Haller
250eb14de1 Bump gocui 2024-08-24 10:35:59 +02:00
Stefan Haller
61ae5e16ae
Improve mouse support for commit message panel (#3836)
#### PR Description

* Fix some minor problems related to cursor movement in an auto-wrapped
  commit message
* Allow clicking in an editable view to set the cursor (most useful in
  longer commit descriptions)
* Allow switching between commit message and description by clicking
2024-08-24 10:29:44 +02:00
Stefan Haller
e1efbfc842 Make it possible to scroll the commit description with the mouse wheel
It is just unexpected and confusing when it isn't.

There's something weird about the cursor position when scrolling it out of view;
it will be shown clamped to the visible area of the view (as if it had moved in
the opposite direction than the scroll direction), but then when you type
something again, or just move the cursor with the arrow keys, the view will jump
back to where the cursor really was. This looks confusing, and it might be
reason enough not to allow scrolling the view at all.
2024-08-24 10:21:30 +02:00
Stefan Haller
7d486cabeb Allow switching between commit message and description by clicking
It is annoying to have to tab to the description first before you can set the
cursor there by clicking.
2024-08-24 10:21:30 +02:00
Stefan Haller
c2e953a09f Cleanup: use the right context for CommitDescriptionController.Context()
It doesn't seem to be used by anything, it looks like we only need to implement
the method so that the IController interface is satisfied. But still, it doesn't
hurt to be correct here, and might avoid confusion in the future when somebody
does try to use the method.
2024-08-24 10:21:30 +02:00
Stefan Haller
59450c7d12 Bump gocui 2024-08-24 10:21:25 +02:00
Jesse Duffield
ca9e006cca
Fix range select -> stage failure when deleted file is already staged (#3631)
- **PR Description**

Fix range select -> stage failure when deleted file is already staged.

Fixes https://github.com/jesseduffield/lazygit/issues/3603

- **Please check if the PR fulfills these requirements**

* [ ] 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)
* [ ] Text is internationalised (see
[here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation))
* [ ] Docs have been updated if necessary
* [x] You've read through your own file changes for silly mistakes etc

<!--
Be sure to name your PR with an imperative e.g. 'Add worktrees view'
see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for
examples
-->
2024-08-24 10:31:46 +10:00