@@ -105,7 +105,7 @@ module.exports = {
105
105
inline . show ( editor , completions [ 3 ] , "f" ) ;
106
106
editor . renderer . $loop . _flush ( ) ;
107
107
assert . strictEqual ( getAllLines ( ) , textBase + "function foo() {" ) ;
108
- assert . strictEqual ( editor . renderer . $ghostTextWidget . el . innerHTML , `<div> console.log('test');</div><div> } </div>` ) ;
108
+ assert . strictEqual ( editor . renderer . $ghostTextWidget . el . innerHTML , `<div><span class="ace_ghost_text"> console.log('test');</span></ div><div><span class="ace_ghost_text"> }</span><span></span> </div>` ) ;
109
109
done ( ) ;
110
110
} ,
111
111
"test: boundary tests" : function ( done ) {
@@ -314,7 +314,69 @@ module.exports = {
314
314
inline . show ( editor , completions [ 8 ] , "f" ) ;
315
315
editor . renderer . $loop . _flush ( ) ;
316
316
assert . strictEqual ( getAllLines ( ) , textBase + "foo suggestion with a" ) ;
317
- assert . strictEqual ( editor . renderer . $ghostTextWidget . el . innerHTML , `<div> </div><div> </div><div>gap</div>` ) ;
317
+ assert . strictEqual ( editor . renderer . $ghostTextWidget . el . innerHTML , `<div><span class="ace_ghost_text"> </span></div><div><span class="ace_ghost_text"> </span></div><div><span class="ace_ghost_text">gap</span><span></span></div>` ) ;
318
+ done ( ) ;
319
+ } ,
320
+ "test: moves tokens to the right of cursor to the end of ghost text for multi line ghost text" : function ( done ) {
321
+ editor . execCommand ( "removetolinestarthard" ) ;
322
+ editor . execCommand ( "insertstring" , "f hi I should be hidden" ) ;
323
+ editor . execCommand ( "gotolinestart" ) ;
324
+ editor . execCommand ( "gotoright" ) ;
325
+ editor . renderer . $loop . _flush ( ) ;
326
+ assert . equal ( editor . renderer . $ghostTextWidget , null ) ;
327
+ inline . show ( editor , completions [ 8 ] , "f" ) ;
328
+ editor . renderer . $loop . _flush ( ) ;
329
+ assert . strictEqual ( getAllLines ( ) , textBase . replaceAll ( " " , "" ) + "foo suggestion with a hi I should be hidden" ) ;
330
+
331
+ // The string to the right of the cursor should be hidden tokens now.
332
+ var tokens = editor . session . getTokens ( 2 ) ;
333
+ assert . strictEqual ( tokens [ 2 ] . value , " hi I should be hidden" ) ;
334
+ assert . strictEqual ( tokens [ 2 ] . type , "hidden_token" ) ;
335
+
336
+ // And should be added to the ghost text widget.
337
+ assert . strictEqual ( editor . renderer . $ghostTextWidget . el . textContent , " gap hi I should be hidden" ) ;
338
+
339
+ // Hide inline
340
+ inline . hide ( ) ;
341
+ editor . renderer . $loop . _flush ( ) ;
342
+ assert . equal ( editor . renderer . $ghostTextWidget , null ) ;
343
+
344
+ // Text to the right of the cursor should be tokenized normally again.
345
+ var tokens = editor . session . getTokens ( 2 ) ;
346
+ assert . strictEqual ( tokens [ 0 ] . value , "f hi I should be hidden" ) ;
347
+ assert . strictEqual ( tokens [ 0 ] . type , "text" ) ;
348
+
349
+ done ( ) ;
350
+ } ,
351
+ "test: moves tokens to the right of cursor to the end of ghost text for multi line ghost text when triggered inside token" : function ( done ) {
352
+ editor . execCommand ( "removetolinestarthard" ) ;
353
+ editor . execCommand ( "insertstring" , "fhi I should be hidden" ) ;
354
+ editor . execCommand ( "gotolinestart" ) ;
355
+ editor . execCommand ( "gotoright" ) ;
356
+ editor . renderer . $loop . _flush ( ) ;
357
+ assert . equal ( editor . renderer . $ghostTextWidget , null ) ;
358
+ inline . show ( editor , completions [ 8 ] , "f" ) ;
359
+ editor . renderer . $loop . _flush ( ) ;
360
+ assert . strictEqual ( getAllLines ( ) , textBase . replaceAll ( " " , "" ) + "foo suggestion with ahi I should be hidden" ) ;
361
+
362
+ // The string to the right of the cursor should be hidden tokens now.
363
+ var tokens = editor . session . getTokens ( 2 ) ;
364
+ assert . strictEqual ( tokens [ 2 ] . value , "hi I should be hidden" ) ;
365
+ assert . strictEqual ( tokens [ 2 ] . type , "hidden_token" ) ;
366
+
367
+ // And should be added to the ghost text widget.
368
+ assert . strictEqual ( editor . renderer . $ghostTextWidget . el . textContent , " gaphi I should be hidden" ) ;
369
+
370
+ // Hide inline
371
+ inline . hide ( ) ;
372
+ editor . renderer . $loop . _flush ( ) ;
373
+ assert . equal ( editor . renderer . $ghostTextWidget , null ) ;
374
+
375
+ // Text to the right of the cursor should be tokenized normally again.
376
+ var tokens = editor . session . getTokens ( 2 ) ;
377
+ assert . strictEqual ( tokens [ 0 ] . value , "fhi I should be hidden" ) ;
378
+ assert . strictEqual ( tokens [ 0 ] . type , "text" ) ;
379
+
318
380
done ( ) ;
319
381
} ,
320
382
tearDown : function ( ) {
0 commit comments