jesseduffield.lazygit/pkg/gui
Jesse Duffield d84dfc23e7 Rely on model rather than view to focus a point
Currently when we want to focus a point on a view (i.e. highlight a
line and ensure it's within the bounds of a view's box, we use the
LinesHeight method on the view to work out how many lines in total
there are.

This is bad because for example if we come back from editing a file,
the view will have no contents so LinesHeight == 0, but we might
be trying to select line 10 because there are actual ten things we
expect to be rendered already. This causes a crash when e.g. 10 is
greater than the height of the view.

So we need to pass in to our FocusPoint method the actual number of
items we want to render, rather than having the method rely on the
LinesHeight, so that the method knows to scroll a bit before setting
the cursor's y position.

Unfortunately this makes for some awkward code with our current setup.
We don't have a good interface type on these state objects so we now
need to explicitly obtain the len() of whatever array we're rendering.

In the case of the menu panel this is even more awkward because the items
list is just an interface{} and it's not easy to get the list of that, so
now when we instantiate a menu we need to pass in the count of items
as well.

The better solution would be to define an interface with a getItems
and getLength method and have all these item arrays become structs
implementing the interface, but I am too lazy to do this right now :)
2019-03-23 11:54:25 +11:00
..
app_status_manager.go show loading status for rebasing events 2019-03-03 15:21:33 +11:00
branches_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
commit_files_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
commit_message_panel.go Make it easier to run sync/async commands, switch to interactive rebase when rebasing on branches 2019-02-24 10:58:15 +11:00
commits_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
confirmation_panel.go add loading panel 2019-02-16 12:03:22 +11:00
context.go mouse support 2019-03-02 17:49:30 +11:00
credentials_panel.go post-merge cleanup 2019-02-11 21:07:12 +11:00
files_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
gui.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
keybindings.go allow adding a file viewed from the commit files panel 2019-03-16 10:20:27 +11:00
menu_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
merge_panel.go i18n for rebase loading states 2019-03-03 16:11:20 +11:00
options_menu_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
rebase_options_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
recent_repos_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
staging_panel.go don't crash if we have no lines to stage 2019-03-03 15:48:01 +11:00
stash_panel.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00
status_panel.go organise keybindings better 2019-03-22 20:20:06 +11:00
theme.go bump dependencies 2018-08-18 14:20:19 +10:00
updates.go move update quit confirmation function into updates file 2018-08-27 20:26:49 +10:00
view_helpers.go Rely on model rather than view to focus a point 2019-03-23 11:54:25 +11:00