~adnano/astronaut

4fcd21086317b018784b301c11f535f3363e7064 — Adnan Maolood 5 months ago 61c818e
command: Remove 'Already at...' messages for back/forward
2 files changed, 6 insertions(+), 14 deletions(-)

M command.go
M tab.go
M command.go => command.go +2 -6
@@ 202,17 202,13 @@ func cmdCancel(b *Browser, args ...string) error {

func cmdBack(b *Browser, args ...string) error {
	tab := b.tabs[b.tab]
	if !tab.Back() {
		b.Message("Already at beginning of history")
	}
	tab.Back()
	return nil
}

func cmdForward(b *Browser, args ...string) error {
	tab := b.tabs[b.tab]
	if !tab.Forward() {
		b.Message("Already at end of history")
	}
	tab.Forward()
	return nil
}


M tab.go => tab.go +4 -8
@@ 259,9 259,9 @@ func (t *Tab) Cancel() {
}

// Back moves back in history.
func (t *Tab) Back() bool {
func (t *Tab) Back() {
	if t.Busy() {
		return false
		return
	}
	t.mu.Lock()
	defer t.mu.Unlock()


@@ 269,15 269,13 @@ func (t *Tab) Back() bool {
	if t.page > 0 {
		t.page--
		t.restoreScroll()
		return true
	}
	return false
}

// Forward moves forward in history.
func (t *Tab) Forward() bool {
func (t *Tab) Forward() {
	if t.Busy() {
		return false
		return
	}
	t.mu.Lock()
	defer t.mu.Unlock()


@@ 285,9 283,7 @@ func (t *Tab) Forward() bool {
	if t.page < len(t.pages)-1 {
		t.page++
		t.restoreScroll()
		return true
	}
	return false
}

func (t *Tab) saveScroll() {