1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-04-19 17:02:18 +03:00

23 Commits

Author SHA1 Message Date
Stefan Haller
2828fb94fb Rewrap patch when view width changes
This makes it so that when the staging view is resized, we keep the same patch
line selected (as opposed to the same view line, which may correspond to a
different patch line after resizing). It doesn't seem like a terribly important
feature for resizing the window, but it is essential when initially entering the
staging view: we select the first line of the first hunk in this case, but we do
that before layout runs. At layout time the view is then split into
unstaged/staged changes, and if this split is horizontal, the view gets narrower
and may be wrapped in a different way. With this commit we ensure that the first
line of the first hunk is still selected after that.
2024-12-23 12:24:09 +01:00
Stefan Haller
5213a9de32 Handle wrapped lines in patch explorer state
So far, lines in the view corresponded 1:1 to lines in the patch. Once we turn
on wrapping for the staging view (which we don't do yet), this is no longer
true, so we need to convert from view lines to patch lines or vice versa all
over the place.
2024-12-23 12:24:09 +01:00
Stefan Haller
f6f2a52dee Bump gocui and adapt lazygit code
Original commit message of the gocui change:

This fixes View.Size, Width and Height to be the correct (outer) size of a view
including its frame, and InnerSize/InnerWidth/InnerHeight to be the usable
client area exluding the frame. Previously, Size was actually the InnerSize (and
a lot of client code used it as such, so these need to be changed to InnerSize).
InnerSize, on the other hand, was *one* less than Size (not two, as you would
have expected), and in many cases this was made up for at call sites by adding 1
(e.g. in calcRealScrollbarStartEnd, parseInput, and many other places in the
lazygit code).

There are still some weird things left that I didn't address here:
- a view's lower-right coordinates (x1/y1) are one less than you would expect.
  For example, a view with a 2x2 client area like this:
    ╭──╮
    │ab│
    │cd│
    ╰──╯
  in the top-left corner of the screen (x0 and y0 both zero) has x1/xy at 3, not
  4 as would be more natural.
- a view without a frame has its coordinates extended by 1 on all sides; to
  illustrate, the same 2x2 view as before but without a frame, sitting in the
  top-left corder of the screen, has coordinates x0=-1, y0=-1, x1=2, y1=2. This
  is highly confusing and unexpected.

I left these as they are because they would be even more of a breaking change,
and also because they don't have quite as much of an impact on general app code.
2024-12-01 10:40:08 +01:00
Stefan Haller
f08b3e9e1d Cleanup: remove isFocused parameter from GetContentToRender and related methods
It became unused in f3eb180f75.
2024-10-18 22:46:48 +02:00
Stefan Haller
8302575078 Remove return value of Focus-related functions 2024-09-06 08:45:48 +02:00
Stefan Haller
8edcd71234 Remove return value of IPatchExplorerContext.Render, RenderAndFocus, and NavigateTo 2024-09-06 08:45:48 +02:00
Stefan Haller
5659f1f3e9 Bump gocui
And adapt client code.
2024-09-06 08:45:48 +02:00
Stefan Haller
94d6f4dae7 Replace IsCurrentContext() with Context().IsCurrent() 2024-08-17 11:14:51 +02:00
Stefan Haller
6a6316cfb6 Use model searching in commits (and sub-commits) view 2024-06-23 11:43:12 +02:00
Stefan Haller
44ad36bb39 Add type assertions for all searchable contexts
We want to add an additional method to ISearchableContext later in this branch,
and this will make sure that we don't forget to implement it in any concrete
context.
2024-06-23 11:43:12 +02:00
Jesse Duffield
f3eb180f75 Standardise display of range selection across views
We're not fully standardising here: different contexts can store their range state however
they like. What we are standardising on is that now the view is always responsible for
highlighting the selected lines, meaning the context/controller needs to tell the view
where the range start is.

Two convenient benefits from this change:
1) we no longer need bespoke code in integration tests for asserting on selected lines because
we can just ask the view
2) line selection in staging/patch-building/merge-conflicts views now look the same as in
list views i.e. the highlight applies to the whole line (including trailing space)

I also noticed a bug with merge conflicts not rendering the selection on focus though I suspect
it wasn't a bug with any real consequences when the view wasn't displaying the selection.

I'm going to scrap the selectedRangeBgColor config and just let it use the single line
background color. Hopefully nobody cares, but there's really no need for an extra config.
2024-01-19 10:47:21 +11:00
Jesse Duffield
c0c3aac02e Support non-sticky range selection in patch explorer views 2024-01-19 10:47:21 +11:00
Stefan Haller
79c11a0458 If selected line is outside, move it to the middle of the view
Previously, the current line was only moved as much as necessary so that it's in
view again. This had the problem that when jumping downwards from hunk to hunk
with the right-arrow key, only the first line of the new hunk was shown at the
bottom of the window. I prefer to put the selected line in the middle of the
view in this case, so that I can see more of the newly selected hunk.

This has the consequence that when scrolling through the view line by line using
down-arrow, the view jumps by half a screen whenever I reach the bottom. I can
see how some users might be opposed to this change, but I happen to like it too,
because it allows me to see more context of what's ahead.
2023-08-15 11:40:40 +02:00
Jesse Duffield
a9e2c8129f Introduce filtered list view model
We're going to start supporting filtering of list views
2023-07-03 12:54:13 +10:00
Jesse Duffield
f8c9ce33c2 move more actions into controller 2023-04-30 13:19:53 +10:00
Jesse Duffield
43251e7275 split context common from helper common 2023-04-30 13:19:53 +10:00
Jesse Duffield
e2db6a1732 remove context callback opts 2023-04-30 13:19:53 +10:00
Jesse Duffield
509e3efa70 lots more refactoring 2023-04-30 13:19:53 +10:00
Jesse Duffield
c517d1e0a2 update view cursor when selecting new line in patch explorer view 2023-02-18 10:19:34 +11:00
stk
8cad8cda8f Don't bother setting view cursor pos for staging/stagingSecondary views
Now that the cursor highlight is never shown (see previous commit), there's no
reason to update the cursor position any more.
2023-02-15 21:32:21 +01:00
Jesse Duffield
755ae0ef84 add deadlock mutex package
write to deadlock stderr after closing gocui

more deadlock checking
2022-08-07 11:16:14 +10:00
Jesse Duffield
7410acd1aa move merge conflicts code into controller 2022-08-07 11:16:03 +10:00
Jesse Duffield
524bf83a4a refactor to only have one context per view 2022-08-06 13:49:11 +10:00