From 86a6a1e7d76cd7a578a6914b66bec29f527fd996 Mon Sep 17 00:00:00 2001 From: Daniel Milde Date: Thu, 15 Feb 2024 20:50:33 +0100 Subject: [PATCH] fix: check if type matches for selected device fixes #315 --- tui/actions_test.go | 16 ++++++++++++++++ tui/tui.go | 5 ++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tui/actions_test.go b/tui/actions_test.go index c64212797..b4d2af049 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 3d800f797..ae2b2f663 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)