@@ -282,6 +282,53 @@ suite('Public API', function () {
282
282
assert . equal ( mq . isUserSelecting ( ) , false ) ;
283
283
} ) ;
284
284
285
+ test ( 'selection restoration shows blinking cursor' , function ( ) {
286
+ mq . latex ( 'a+b+c' ) ;
287
+ mq . focus ( ) ;
288
+
289
+ assert . ok (
290
+ mq . el ( ) . querySelector ( '.mq-cursor' ) ,
291
+ 'cursor shows up to start'
292
+ ) ;
293
+
294
+ // Create a selection covering entire content
295
+ mq . select ( ) ;
296
+ var selectionSnapshot = mq . selection ( ) ;
297
+
298
+ assert . ok (
299
+ ! mq . el ( ) . querySelector ( '.mq-cursor' ) ,
300
+ 'cursor should not be in DOM during selection'
301
+ ) ;
302
+
303
+ // Move to a single cursor position (no selection)
304
+ mq . moveToLeftEnd ( ) ;
305
+ var caretSnapshot = mq . selection ( ) ;
306
+
307
+ assert . ok (
308
+ mq . el ( ) . querySelector ( '.mq-cursor' ) ,
309
+ 'cursor should be in DOM at single position'
310
+ ) ;
311
+ assert . equal (
312
+ caretSnapshot . startIndex ,
313
+ caretSnapshot . endIndex ,
314
+ 'should be a caret position'
315
+ ) ;
316
+
317
+ // Restore the full selection
318
+ mq . selection ( selectionSnapshot ) ;
319
+ assert . ok (
320
+ ! mq . el ( ) . querySelector ( '.mq-cursor' ) ,
321
+ 'cursor should not be in DOM during selection'
322
+ ) ;
323
+
324
+ // Now restore the single caret position - this should show the blinking cursor
325
+ mq . selection ( caretSnapshot ) ;
326
+ assert . ok (
327
+ mq . el ( ) . querySelector ( '.mq-cursor' ) ,
328
+ 'cursor should be in DOM and visible after restoring caret position'
329
+ ) ;
330
+ } ) ;
331
+
285
332
test ( '.mathspeak()' , function ( ) {
286
333
function assertMathSpeakEqual ( a , b ) {
287
334
assert . equal ( normalize ( a ) , normalize ( b ) ) ;
0 commit comments