summaryrefslogtreecommitdiffstats
path: root/pkg/gui
AgeCommit message (Collapse)Author
2024-06-23Highlight inactive selection in boldStefan Haller
An inactive selection is one where the view is part of the context stack, but not the active view. For example, the files view when you enter the staging panel, or any view when you open a panel.
2024-06-23Clear highlight in HandleFocusLostStefan Haller
Remove the old mechanism of clearing the highlight in Layout. This fixes a problem with a wrong highlight showing up in the staging panel when entering a file with only staged changes. Reproduction recipe: 1. stage all changes in a file by pressing space on it in the files panel 2. enter the staged changes panel by pressing enter 3. unstage one of the changes This makes the unstaged changes panel visible, but keeps the focus in the staged changes panel. However, the highlight in the unstaged changes view becomes visible, as if it were focused. To explain why this happens, you need to know how the selection highlighting of a view is turned on or off. It is turned on when it gains the focus, i.e. when ActivateFocus is called on it, which in turn happens when PushContext is called. It is turned off in Layout when gocui sees that the current view is no longer the same as last time, in which case it calls onViewFocusLost on the previous current view. This mechanism only works reliably when there is at most one PushContext call per event handler. If there is more than one, then the first one gets its highlight turned on, then the second one, but since gocui has never seen the first one as the active view in Layout, it doesn't get the highlight turned off again even though it should. And this happens in the above scenario. When pressing enter on a file with only staged changes, we first push the staging context (in FilesController.EnterFile), and then later we push the stagingSecondary context when we realize we only have staged changes. This leaves the highlight of the staging context on.
2024-06-23Use utils.StringWidth to optimize rendering performanceStefan Haller
runewidth.StringWidth is an expensive call, even if the input string is pure ASCII. Improve this by providing a wrapper that short-circuits the call to len if the input is ASCII. Benchmark results show that for non-ASCII strings it makes no noticable difference, but for ASCII strings it provides a more than 200x speedup. BenchmarkStringWidthAsciiOriginal-10 718135 1637 ns/op BenchmarkStringWidthAsciiOptimized-10 159197538 7.545 ns/op BenchmarkStringWidthNonAsciiOriginal-10 486290 2391 ns/op BenchmarkStringWidthNonAsciiOptimized-10 502286 2383 ns/op
2024-06-23Rerender fewer views when their width changesStefan Haller
In d5b4f7bb3e and 58a83b0862 we introduced a combined mechanism for rerendering views when either their width changes (needed for the branches view which truncates long branch names), or the screen mode (needed for those views that display more information in half or full screen mode, e.g. the commits view). This was a bad idea, because it unnecessarily rerenders too many views when just their width changes, which causes a noticable lag. This is a problem, for example, when selecting a file in the files panel that has only unstaged changes, and then going to one that has both staged and unstaged changes; this splits the main view, causing the side panels to become a bit narrower, and rerendering all those views took almost 500ms on my machine. Another similar example is entering or leaving staging mode. Fix this by being more specific about which views need rerendering under what conditions; this improves the time it takes to rerender in the above scenarios from 450-500s down to about 20ms. This reintroduces the code that was removed in 58a83b0862, but in a slightly different way.
2024-06-23Don't redraw remote branches view when its width changesStefan Haller
The rendering of remote branches is in no way dependent on the width of the view (or the screen mode). Unlike in the local branches view, we don't truncate long branch names here (because there's no more information after them). This is an error introduced in d5b4f7bb3e.
2024-06-23Show radio buttons in the show log graph and commit sort order menusStefan Haller
2024-06-23Show radio buttons in the sort order menu for branchesStefan Haller
2024-06-23Support showing checkboxes or radio buttons in menusStefan Haller
For checkboxes it probably doesn't really make sense to use them yet, because we'd have to find a way how you can toggle them without closing the dialog; but we already provide rendering for them to lay the ground. But radio buttons can be used already, because for those it is ok to close the dialog when choosing a different option (as long as there is only one grounp of radio buttons in the panel, that is).
2024-06-23Always show the "Discard unchanged changes" menu itemStefan Haller
Strike it through if not applicable. This will hopefully help with confusion about the meaning of "all" in the "Discard all changes" entry; some people misunderstand this to mean all changes in the working copy. Seeing the "Discard unstaged changes" item next to it hopefully makes it clearer that "all" is meant in contrast to that.
2024-06-23Fix custom patch operations on added filesStefan Haller
Several custom patch commands on parts of an added file would fail with the confusing error message "error: new file XXX depends on old contents". These were dropping the custom patch from the original commit, moving the patch to a new commit, moving it to a later commit, or moving it to the index. We fix this by converting the patch header from an added file to a diff against an empty file. We do this not just for the purpose of applying the patch, but also for rendering it and copying it to the clip board. I'm not sure it matters much in these cases, but it does feel more correct for a filtered patch to be presented this way.
2024-06-23Introduce options struct for RenderPatchForFileStefan Haller
We're going to add another argument in the next commit, and that's getting a bit much, especially when most of the arguments are bool and you only see true and false at the call sites without knowing what they mean.
2024-06-23Run PTY tasks after layout so that they get the correct view sizeStefan Haller
This is important when using a pager that draws a horizontal line across the entire width of the view; when changing from a file or directory that has only unstaged (or only staged) changes to one that has both, the main view is split in half, but the PTY task would be run on the view in its old state, so the horizonal line would be too long and wrap around.
2024-06-23Fix possible off-by-one error wrt PTY sizeStefan Haller
All PTYs were created with the size of the main view, on the assumption that main and secondary always have the same size. That's not true though; in horizontal split mode, the width of the two views can differ by one because of rounding, and when using a pager that draws a horizontal line across the width of the view, this is visible and looks very ugly.
2024-06-23Add prompt to the remote branch checkout menuStefan Haller
2024-06-23Add menu promptStefan Haller
This makes it possible to add a prompt to a menu. It will be shown above the menu items, separated from them by a blank line.
2024-06-23Extract function wrapMessageToWidthStefan Haller
This steals even more code from `gocui.lineWrap`. We'll make use of this in the next commit.
2024-06-23Clear keybinding functions in resetHelpersAndControllersStefan Haller
When switching to a repo that was open before, the context tree is reused, so before adding keybinding functions to those contexts again, we need to clear the old ones.
2024-06-23Fix truncation of long branch names containing non-ASCII charactersStefan Haller
2024-06-23Add test demonstrating wrong truncation of branch names containing non-ASCII ↵Stefan Haller
characters
2024-06-23Render the view when scrolling with the wheelStefan Haller
2024-06-23Only render visible portion of the screen for commits viewStefan Haller
2024-06-23Simplify ListContextTrait.FocusLineStefan Haller
When refreshViewportOnChange is true, we would refresh the viewport once at the end of FocusLine, and then we would check at the end of AfterLayout if the origin has changed, and refresh again if so. That's unnecessarily complicated, let's just unconditionally refresh at the end of AfterLayout only.
2024-06-23Log memory usage every 10sStefan Haller
2024-06-23Use model searching in commits (and sub-commits) viewStefan Haller
2024-06-23Add type assertions for all searchable contextsStefan Haller
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-23Cleanup: remove outdated commentStefan Haller
We do show the graph in the left/right view, as of b7673577a2.
2024-06-23Fix searching in the divergence (left/right) viewStefan Haller
Searching in the "Divergence from upstream" view would select the wrong lines. The OnSearchSelect function gets passed a view index, and uses it to select a model line. In most views these are the same, but not in the divergence view (because of the Remote/Local section headers).
2024-06-23Cleanup: reduce some code duplicationStefan Haller
ListContextTrait.OnSearchSelect was introduced in 138be04e65, but it was never called. I can only guess that a planned refactoring wasn't finished here.
2024-06-15Add user config gui.commitAuthorFormatanikiforov
2024-06-12Suspend lazygit when continuing a rebase with exec todosStefan Haller
It's likely that the exec todos are some kind of lengthy build task whose output the user will want to see in the terminal.
2024-06-12Show "exec" todos in the list of rebase todosStefan Haller
Unfortunately it isn't possible to delete them. This would often be useful, but our todo rewriting mechanisms rely on being able to find todos by some identifier (hash for pick, ref for update-ref), and exec todos don't have a unique identifier.
2024-06-10Disregard master commits when finding base commit for fixupStefan Haller
If exactly one candidate from inside the current branch is found, we return that one even if there are also hunks belonging to master commits; we disregard those in this case.
2024-06-10Don't reference Model().Commits multiple timesStefan Haller
Copy the slice into a variable and use that throughout the whole operation; this makes us a little more robust against the model refreshing concurrently.
2024-06-07feat: support range selection for commit attributes amendAzraelSec
2024-06-07feat: let the staging secondary panel change view modeAzraelSec
2024-06-05Don't wait in integration tests when running in headless modeStefan Haller
There's no point in spending time waiting in this case, as nobody can see it.
2024-06-03Add command "Rebase onto base branch" to rebase menuStefan Haller
2024-06-03Remove target branch from title of rebase menuStefan Haller
Put it into the individual menu items instead. Again, this is necessary because we are going to add another entry to the menu that is independent of the selected branch.
2024-06-03Always show rebase menu, even when rebasing is not possibleStefan Haller
Instead, disable the individual entries in the menu. This is necessary because we are going to add another entry to the menu that is independent of the selected branch.
2024-06-03Make "Rebase" show up with "..." in the keybindings menuStefan Haller
2024-06-03Add command "View divergence from base branch"Stefan Haller
2024-06-03Show divergence from base branch in branches listStefan Haller
2024-06-03Remove ColoredBranchStatus and branchStatusColorStefan Haller
Previously the entire status was colored in a single color, so the API made sense. This is going to change in the next commit, so now we must include the color in the string returned from BranchStatus(), which means that callers who need to do hit detection or measure the length need to decolorize it. While we're at it, switch the order of ↑3↓7 to ↓7↑3. For some reason that I can't really explain I find it more logical this way. The software out there is pretty undecided about it, it seems: VS Code puts ↓7 first, and so does the shell prompt that comes with git; git status and git branch -v put "ahead" first though. Shrug.
2024-06-03Factor out CommitLoader.mainBranches into its own class, and store it in ModelStefan Haller
2024-06-03More explicit test of status panel contentStefan Haller
Use Equals instead of Contains for asserting the status view content. This solves the problem that we might assert Contains("↓2 repo"), but what it really shows is "↑1↓2 repo", and the test still succeeds. At best this is confusing. Also, this way we don't have to use the awkward DoesNotContain to check that it really doesn't show a checkmark. To do this, we need to fix two whitespace problems: - there was always a space at the end for no reason. Simply remove it. It was added in efb51eee96, but from looking at that diff it seems it was added accidentally. - there was a space at the beginning if the branch status was empty. This is actually a cosmetic problem, for branches without a status the text was indented by once space. Change this so that the space is added conditionally. It's a bit awkward that we have to use Decolorise here, but this will go away again later in this branch.
2024-06-01Make "Find base commit for fixup" work with hunks with only added linesStefan Haller
To understand what this does and why, read the design document that I'm about to add in the next commit.
2024-06-01Extract a function findCommitStefan Haller
It's not much code, but it turns three lines of code into one, and since we need to do this a few more times in the next commit, it's worth it.
2024-06-01Return errors from blameDeletedLines instead of just logging themStefan Haller
I guess when I originally wrote this code I just didn't know how to do that...
2024-06-01Also return hunks with only added lines from parseDiffStefan Haller
We aren't using them, yet, except for deciding whether to show the warning about hunks with only added lines. Add a bit of test coverage for parseDiff while we're at it.
2024-06-01Make parseDiff a non-member function so that we can test it more easilyStefan Haller