summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Milde <daniel@milde.cz>2021-11-09 11:05:31 +0100
committerDaniel Milde <daniel@milde.cz>2021-11-09 11:05:31 +0100
commitc60f4ca729c2f86f6fe749693e4f9234960247db (patch)
tree7d4d4c4427c082c8e7496a8482506ebb3479cae8
parent1733548650196f75bb4293110915c9a746c2a075 (diff)
fix: do not show help if file info is shownv5.10.0
-rw-r--r--tui/actions_test.go10
-rw-r--r--tui/keys.go55
-rw-r--r--tui/keys_test.go2
3 files changed, 33 insertions, 34 deletions
diff --git a/tui/actions_test.go b/tui/actions_test.go
index c4880a1..b5dc8af 100644
--- a/tui/actions_test.go
+++ b/tui/actions_test.go
@@ -292,8 +292,6 @@ func TestShowInfo(t *testing.T) {
ui.keyPressed(tcell.NewEventKey(tcell.KeyRight, 'l', 0))
ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
- ui.table.Select(2, 0)
- ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
assert.True(t, ui.pages.HasPage("info"))
@@ -324,10 +322,12 @@ func TestShowInfoBW(t *testing.T) {
ui.keyPressed(tcell.NewEventKey(tcell.KeyRight, 'l', 0))
ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
- ui.table.Select(2, 0)
- ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
assert.True(t, ui.pages.HasPage("info"))
+
+ ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
+
+ assert.False(t, ui.pages.HasPage("info"))
}
func TestShowInfoWithHardlinks(t *testing.T) {
@@ -361,8 +361,6 @@ func TestShowInfoWithHardlinks(t *testing.T) {
ui.keyPressed(tcell.NewEventKey(tcell.KeyRight, 'l', 0))
ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
- ui.table.Select(2, 0)
- ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
assert.True(t, ui.pages.HasPage("info"))
diff --git a/tui/keys.go b/tui/keys.go
index 9d8a605..739cc11 100644
--- a/tui/keys.go
+++ b/tui/keys.go
@@ -18,43 +18,26 @@ func (ui *UI) keyPressed(key *tcell.EventKey) *tcell.EventKey {
if key.Key() == tcell.KeyEsc || key.Rune() == 'q' {
if ui.pages.HasPage("help") {
ui.pages.RemovePage("help")
- _, page := ui.pages.GetFrontPage()
- ui.app.SetFocus(page)
+ ui.app.SetFocus(ui.table)
return nil
}
if ui.pages.HasPage("info") {
ui.pages.RemovePage("info")
- _, page := ui.pages.GetFrontPage()
- ui.app.SetFocus(page)
+ ui.app.SetFocus(ui.table)
return nil
}
}
-
- if key.Rune() == 'i' {
- if ui.pages.HasPage("info") {
+
+ if ui.pages.HasPage("info") {
+ switch key.Rune() {
+ case 'i':
ui.pages.RemovePage("info")
- _, page := ui.pages.GetFrontPage()
- ui.app.SetFocus(page)
+ ui.app.SetFocus(ui.table)
+ return nil
+ case '?':
return nil
}
- }
-
- switch key.Rune() {
- case 'Q':
- ui.app.Stop()
- fmt.Fprintf(ui.output, "%s\n", ui.currentDirPath)
- return nil
- case 'q':
- ui.app.Stop()
- return nil
- case 'b':
- ui.spawnShell()
- return nil
- case '?':
- ui.showHelp()
- }
- if ui.pages.HasPage("info") {
if key.Key() == tcell.KeyUp ||
key.Key() == tcell.KeyDown ||
key.Rune() == 'j' ||
@@ -71,6 +54,26 @@ func (ui *UI) keyPressed(key *tcell.EventKey) *tcell.EventKey {
defer ui.showInfo() // refresh file info after any change
}
+ switch key.Rune() {
+ case 'Q':
+ ui.app.Stop()
+ fmt.Fprintf(ui.output, "%s\n", ui.currentDirPath)
+ return nil
+ case 'q':
+ ui.app.Stop()
+ return nil
+ case 'b':
+ ui.spawnShell()
+ return nil
+ case '?':
+ if ui.pages.HasPage("help") {
+ ui.pages.RemovePage("help")
+ ui.app.SetFocus(ui.table)
+ return nil
+ }
+ ui.showHelp()
+ }
+
if ui.pages.HasPage("confirm") ||
ui.pages.HasPage("progress") ||
ui.pages.HasPage("deleting") ||
diff --git a/tui/keys_test.go b/tui/keys_test.go
index 1141767..8a83dd3 100644
--- a/tui/keys_test.go
+++ b/tui/keys_test.go
@@ -703,8 +703,6 @@ func TestShowInfoAndMoveAround(t *testing.T) {
ui.keyPressed(tcell.NewEventKey(tcell.KeyRight, 'l', 0))
ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
- ui.table.Select(2, 0)
- ui.keyPressed(tcell.NewEventKey(tcell.KeyRune, 'i', 0))
assert.True(t, ui.pages.HasPage("info"))