@@ -95,6 +95,37 @@ func TestBasic(t *testing.T) {
9595 })
9696}
9797
98+ func TestInitialFilePathPositionsCursor (t * testing.T ) {
99+ curTestDir := filepath .Join (testDir , "TestInitialFilePathPositionsCursor" )
100+ dir1 := filepath .Join (curTestDir , "dir1" )
101+ file1 := filepath .Join (dir1 , "file1.txt" )
102+
103+ utils .SetupDirectories (t , curTestDir , dir1 )
104+ utils .SetupFiles (t , file1 )
105+ t .Cleanup (func () { _ = os .RemoveAll (curTestDir ) })
106+
107+ // Initialize model with a file path; cursor should land on that file
108+ m := defaultTestModel (file1 )
109+
110+ // Populate elements for the panel and apply target cursor
111+ m .getFilePanelItems ()
112+
113+ panel := m .getFocusedFilePanel ()
114+ require .Equal (t , dir1 , panel .location , "Panel should open on parent directory" )
115+ require .NotEmpty (t , panel .element , "Panel elements should be populated" )
116+
117+ // Find file in the element list and compare with cursor index
118+ targetIdx := - 1
119+ for i , el := range panel .element {
120+ if el .name == filepath .Base (file1 ) {
121+ targetIdx = i
122+ break
123+ }
124+ }
125+ require .NotEqual (t , - 1 , targetIdx , "Target file must exist in panel elements" )
126+ assert .Equal (t , targetIdx , panel .cursor , "Cursor should point to the target file" )
127+ }
128+
98129func TestQuit (t * testing.T ) {
99130 // Test
100131 // 1 - Normal quit
0 commit comments