File tree 3 files changed +17
-1
lines changed
3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,10 @@ var completions = [
50
50
{
51
51
value : "long\nlong\nlong\nlong\nlong\nlong" . repeat ( 100 ) ,
52
52
score : 0
53
+ } ,
54
+ {
55
+ value : "foo suggestion with a\n\n\ngap" ,
56
+ score : 0
53
57
}
54
58
] ;
55
59
@@ -305,6 +309,14 @@ module.exports = {
305
309
} , 50 ) ;
306
310
} , 50 ) ;
307
311
} ,
312
+ "test: renders multi-line ghost text with empty lines" : function ( done ) {
313
+ assert . equal ( editor . renderer . $ghostTextWidget , null ) ;
314
+ inline . show ( editor , completions [ 8 ] , "f" ) ;
315
+ editor . renderer . $loop . _flush ( ) ;
316
+ assert . strictEqual ( getAllLines ( ) , textBase + "foo suggestion with a" ) ;
317
+ assert . strictEqual ( editor . renderer . $ghostTextWidget . el . innerHTML , `<div> </div><div> </div><div>gap</div>` ) ;
318
+ done ( ) ;
319
+ } ,
308
320
tearDown : function ( ) {
309
321
inline . destroy ( ) ;
310
322
editor . destroy ( ) ;
Original file line number Diff line number Diff line change @@ -1785,6 +1785,10 @@ class VirtualRenderer {
1785
1785
// If the line is wider than the viewport, wrap the line
1786
1786
if ( el . wrapped ) chunkDiv . className = "ghost_text_line_wrapped" ;
1787
1787
1788
+ // If a given line doesn't have text (e.g. it's a line of whitespace), set a space as the
1789
+ // textcontent so that browsers render the empty line div.
1790
+ if ( el . text . length === 0 ) el . text = " " ;
1791
+
1788
1792
chunkDiv . appendChild ( dom . createTextNode ( el . text ) ) ;
1789
1793
widgetDiv . appendChild ( chunkDiv ) ;
1790
1794
} ) ;
Original file line number Diff line number Diff line change @@ -395,7 +395,7 @@ module.exports = {
395
395
editor . renderer . $loop . _flush ( ) ;
396
396
assert . equal ( editor . renderer . content . textContent , "abcdefThis is a long test text that is longer than " ) ;
397
397
398
- assert . equal ( editor . session . lineWidgets [ 0 ] . el . innerHTML , `<div class="ghost_text_line_wrapped">30 characters</div><div></div><div>Ghost3</div>` ) ;
398
+ assert . equal ( editor . session . lineWidgets [ 0 ] . el . innerHTML , `<div class="ghost_text_line_wrapped">30 characters</div><div> </div><div>Ghost3</div>` ) ;
399
399
400
400
editor . removeGhostText ( ) ;
401
401
You can’t perform that action at this time.
0 commit comments