From c30e96b66815ff1d4e15190dad87486e2e24b133 Mon Sep 17 00:00:00 2001 From: giuliano Date: Tue, 11 Jul 2023 00:35:16 +0200 Subject: [PATCH] Fix crash when indexing raw content for a url --- pkg/display/display.go | 4 ++++ pkg/display/input.go | 5 ++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/pkg/display/display.go b/pkg/display/display.go index ebd2bb5..ea3e2a4 100644 --- a/pkg/display/display.go +++ b/pkg/display/display.go @@ -153,6 +153,10 @@ func (d *display) currentRow() int { return d.cy - 1 + d.startoff } +func (d *display) currentUrl() string { + return string(d.raw[d.currentRow()]) +} + func (d *display) resetCoordinates() { d.cy = 1 d.cx = 1 diff --git a/pkg/display/input.go b/pkg/display/input.go index 1578546..5488cf5 100644 --- a/pkg/display/input.go +++ b/pkg/display/input.go @@ -168,13 +168,12 @@ func (d *display) whileReading(input byte, quitC chan bool) { case ascii.ENTER: { - url := string(d.raw[d.currentRow()]) switch d.currentSection { case URLS_LIST: - d.loadArticlesList(url) + d.loadArticlesList(d.currentUrl()) case ARTICLES_LIST: - d.loadArticleText(url) + d.loadArticleText(d.currentUrl()) } }