summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Milde <daniel@milde.cz>2024-02-15 20:50:33 +0100
committerDaniel Milde <daniel@milde.cz>2024-02-15 20:56:12 +0100
commit9d88ea1f5efe1c8e2444eed926f9c64c211ec039 (patch)
tree8060264c7b1489533baa2f167759b07e1ec175ee
parent52079feb1162dd15412923f365475d1ecbc97f82 (diff)
fix: check if type matches for selected device
fixes #315
-rw-r--r--tui/actions_test.go16
-rw-r--r--tui/tui.go5
2 files changed, 20 insertions, 1 deletions
diff --git a/tui/actions_test.go b/tui/actions_test.go
index c642127..b4d2af0 100644
--- a/tui/actions_test.go
+++ b/tui/actions_test.go
@@ -85,6 +85,22 @@ func TestDeviceSelected(t *testing.T) {
assert.Contains(t, ui.table.GetCell(1, 0).Text, "bbb")
}
+func TestNilDeviceSelected(t *testing.T) {
+ simScreen := testapp.CreateSimScreen()
+ defer simScreen.Fini()
+
+ app := testapp.CreateMockedApp(false)
+ ui := CreateUI(app, simScreen, &bytes.Buffer{}, true, true, true, false, false)
+ ui.Analyzer = &testanalyze.MockedAnalyzer{}
+ ui.done = make(chan struct{})
+ ui.UseOldSizeBar()
+ ui.SetIgnoreDirPaths([]string{"/xxx"})
+
+ ui.deviceItemSelected(1, 0)
+
+ assert.Equal(t, 0, ui.table.GetRowCount())
+}
+
func TestAnalyzePath(t *testing.T) {
ui := getAnalyzedPathMockedApp(t, true, true, true)
diff --git a/tui/tui.go b/tui/tui.go
index 3d800f7..ae2b2f6 100644
--- a/tui/tui.go
+++ b/tui/tui.go
@@ -255,7 +255,10 @@ func (ui *UI) fileItemSelected(row, column int) {
func (ui *UI) deviceItemSelected(row, column int) {
var err error
- selectedDevice := ui.table.GetCell(row, column).GetReference().(*device.Device)
+ selectedDevice, ok := ui.table.GetCell(row, column).GetReference().(*device.Device)
+ if !ok {
+ return
+ }
paths := device.GetNestedMountpointsPaths(selectedDevice.MountPoint, ui.devices)
ui.IgnoreDirPathPatterns, err = common.CreateIgnorePattern(paths)