@@ -4,8 +4,8 @@ local ui = require('opencode.ui.ui')
44
55describe (' cursor persistence (state)' , function ()
66 before_each (function ()
7- state .set_cursor_position (' input' , nil )
8- state .set_cursor_position (' output' , nil )
7+ state .ui . set_cursor_position (' input' , nil )
8+ state .ui . set_cursor_position (' output' , nil )
99 end )
1010
1111 describe (' renderer.scroll_to_bottom' , function ()
@@ -93,73 +93,73 @@ describe('cursor persistence (state)', function()
9393
9494 describe (' set/get round-trip' , function ()
9595 it (' stores and retrieves input cursor' , function ()
96- state .set_cursor_position (' input' , { 5 , 3 })
97- assert .same ({ 5 , 3 }, state .get_cursor_position (' input' ))
96+ state .ui . set_cursor_position (' input' , { 5 , 3 })
97+ assert .same ({ 5 , 3 }, state .ui . get_cursor_position (' input' ))
9898 end )
9999
100100 it (' stores and retrieves output cursor' , function ()
101- state .set_cursor_position (' output' , { 10 , 0 })
102- assert .same ({ 10 , 0 }, state .get_cursor_position (' output' ))
101+ state .ui . set_cursor_position (' output' , { 10 , 0 })
102+ assert .same ({ 10 , 0 }, state .ui . get_cursor_position (' output' ))
103103 end )
104104
105105 it (' input and output are independent' , function ()
106- state .set_cursor_position (' input' , { 1 , 0 })
107- state .set_cursor_position (' output' , { 99 , 5 })
108- assert .same ({ 1 , 0 }, state .get_cursor_position (' input' ))
109- assert .same ({ 99 , 5 }, state .get_cursor_position (' output' ))
106+ state .ui . set_cursor_position (' input' , { 1 , 0 })
107+ state .ui . set_cursor_position (' output' , { 99 , 5 })
108+ assert .same ({ 1 , 0 }, state .ui . get_cursor_position (' input' ))
109+ assert .same ({ 99 , 5 }, state .ui . get_cursor_position (' output' ))
110110 end )
111111
112112 it (' returns nil for unknown win_type' , function ()
113- assert .is_nil (state .get_cursor_position (' footer' ))
113+ assert .is_nil (state .ui . get_cursor_position (' footer' ))
114114 end )
115115 end )
116116
117117 describe (' normalize_cursor edge cases' , function ()
118118 it (' clamps negative line to 1' , function ()
119- state .set_cursor_position (' input' , { - 5 , 3 })
120- local pos = state .get_cursor_position (' input' )
119+ state .ui . set_cursor_position (' input' , { - 5 , 3 })
120+ local pos = state .ui . get_cursor_position (' input' )
121121 assert .equals (1 , pos [1 ])
122122 end )
123123
124124 it (' clamps negative col to 0' , function ()
125- state .set_cursor_position (' input' , { 1 , - 1 })
126- local pos = state .get_cursor_position (' input' )
125+ state .ui . set_cursor_position (' input' , { 1 , - 1 })
126+ local pos = state .ui . get_cursor_position (' input' )
127127 assert .equals (0 , pos [2 ])
128128 end )
129129
130130 it (' floors fractional values' , function ()
131- state .set_cursor_position (' input' , { 3.7 , 2.9 })
132- local pos = state .get_cursor_position (' input' )
131+ state .ui . set_cursor_position (' input' , { 3.7 , 2.9 })
132+ local pos = state .ui . get_cursor_position (' input' )
133133 assert .equals (3 , pos [1 ])
134134 assert .equals (2 , pos [2 ])
135135 end )
136136
137137 it (' rejects non-table input' , function ()
138- state .set_cursor_position (' input' , ' bad' )
139- assert .is_nil (state .get_cursor_position (' input' ))
138+ state .ui . set_cursor_position (' input' , ' bad' )
139+ assert .is_nil (state .ui . get_cursor_position (' input' ))
140140 end )
141141
142142 it (' rejects table with fewer than 2 elements' , function ()
143- state .set_cursor_position (' input' , { 1 })
144- assert .is_nil (state .get_cursor_position (' input' ))
143+ state .ui . set_cursor_position (' input' , { 1 })
144+ assert .is_nil (state .ui . get_cursor_position (' input' ))
145145 end )
146146
147147 it (' rejects non-numeric elements' , function ()
148- state .set_cursor_position (' input' , { ' a' , ' b' })
149- assert .is_nil (state .get_cursor_position (' input' ))
148+ state .ui . set_cursor_position (' input' , { ' a' , ' b' })
149+ assert .is_nil (state .ui . get_cursor_position (' input' ))
150150 end )
151151
152152 it (' clears position when set to nil' , function ()
153- state .set_cursor_position (' input' , { 5 , 3 })
154- state .set_cursor_position (' input' , nil )
155- assert .is_nil (state .get_cursor_position (' input' ))
153+ state .ui . set_cursor_position (' input' , { 5 , 3 })
154+ state .ui . set_cursor_position (' input' , nil )
155+ assert .is_nil (state .ui . get_cursor_position (' input' ))
156156 end )
157157 end )
158158
159159 describe (' get_window_cursor' , function ()
160160 it (' returns nil for invalid window' , function ()
161- assert .is_nil (state .get_window_cursor (nil ))
162- assert .is_nil (state .get_window_cursor (999999 ))
161+ assert .is_nil (state .ui . get_window_cursor (nil ))
162+ assert .is_nil (state .ui . get_window_cursor (999999 ))
163163 end )
164164
165165 it (' gets cursor from a real window' , function ()
@@ -174,12 +174,12 @@ describe('cursor persistence (state)', function()
174174 })
175175 vim .api .nvim_win_set_cursor (win , { 2 , 3 })
176176
177- local pos = state .get_window_cursor (win )
177+ local pos = state .ui . get_window_cursor (win )
178178 assert .same ({ 2 , 3 }, pos )
179179
180180 -- Manually save to verify persistence path
181- state .set_cursor_position (' output' , pos )
182- assert .same ({ 2 , 3 }, state .get_cursor_position (' output' ))
181+ state .ui . set_cursor_position (' output' , pos )
182+ assert .same ({ 2 , 3 }, state .ui . get_cursor_position (' output' ))
183183
184184 pcall (vim .api .nvim_win_close , win , true )
185185 pcall (vim .api .nvim_buf_delete , buf , { force = true })
0 commit comments