Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- A tab in the top bar can no longer get stuck lifted, drawn in the accent color as if it were being dragged, with no tab moving again until lich restarted. A tab focused by a click and then given Space or Enter was picked up to reorder from the keyboard, and once a click elsewhere took the keyboard it could neither be dropped nor cancelled; it now goes back to its place when it loses focus. A layout tab renamed in the middle of a drag no longer gets stuck the same way.
- A session card no longer grows and shrinks as its agent starts and stops a tool, waits on you or compacts, pushing every card below it up and down. That line now takes the place of the card's path while it shows, and the path comes back when it goes.
- The native window holds less memory for its fonts. A font file asked for more than once, such as the interface and the terminal set in the same family or the bold face that also stands in for semibold, was parsed again each time, about 30MB for a Nerd Font face; it is now parsed once and shared while in use. An interface in a language other than Chinese, Japanese or Korean no longer loads a CJK font at start, tens of megabytes: it does on the first CJK text on screen, drawn meanwhile with a system font. With one Nerd Font for the interface, the terminal and the editor and no CJK on screen, the fonts take 119MB where they took 246MB.
- On macOS, opening lich from the Dock, Launchpad, Spotlight or Finder while it runs with its window closed opens the window again. lich started at login with `--no-window` included, where the click did nothing. Logging out now quits lich the way `lich quit` does, so the next launch does not read it as a crash.
Expand Down
10 changes: 10 additions & 0 deletions native/ui/sortable.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ type sortTarget struct {
// what the button did, so a move and a release queued together drop where the
// move went.
func (s *Sortable) Update(gtx C) (SortDrop, bool) {
// Disabled items register no handler, so the release that would end a
// drag already in the air never arrives.
if s.Disabled && s.active != "" {
s.end()
}
if s.Carry != nil {
s.Carry.hover(gtx)
if s.active != "" && !s.keyboard && s.Carry.carrying == "" {
Expand Down Expand Up @@ -286,6 +291,11 @@ func (s *Sortable) handle(gtx C, t *sortTarget) {
} else if s.focused == t.id {
s.focused = ""
}
// Only the focused item hears Space and Escape, so a keyboard
// drag that loses focus could never end.
if !e.Focus && s.keyboard && s.active == t.id {
s.end()
}
case key.Event:
s.key(t, e)
}
Expand Down
32 changes: 32 additions & 0 deletions native/ui/sortable_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,38 @@ func TestSortableKeyboardEscapeDropsNothing(t *testing.T) {
r.want(t)
}

// The keyboard drops only into a focused item, so focus moving elsewhere (a
// click on the terminal) cancels the drag, or nothing could ever end it.
func TestSortableKeyboardDragEndsWhenFocusLeaves(t *testing.T) {
r := newSortRig()
r.press(onA)
r.release(onA)
r.keys(key.NameSpace)
r.router.Source().Execute(key.FocusCmd{})
r.frame()
if r.s.Dragging() != "" {
t.Errorf("dragging %q after the item lost focus, want none", r.s.Dragging())
}
r.want(t)
}

// A tab that starts a rename mid-drag disables its Sortable, whose items then
// never hear the release: the drag ends there, and the next one lifts.
func TestSortableDisabledMidDragEndsIt(t *testing.T) {
r := newSortRig()
r.press(onA)
r.move(onA.Add(image.Pt(10, 0)))
r.s.Disabled = true
r.release(onB)
r.s.Disabled = false
r.frame()
if r.s.Dragging() != "" {
t.Fatalf("dragging %q after a drag was disabled, want none", r.s.Dragging())
}
r.drag(onA, onA.Add(image.Pt(10, 0)), onB)
r.want(t, SortDrop{ID: "a", Over: "b"})
}

func TestSortableDisabledLiftsNothing(t *testing.T) {
r := newSortRig()
r.s.Disabled = true
Expand Down
Loading