@@ -1417,12 +1417,7 @@ Actual: ${stringify(fullActual)}`);
1417
1417
}
1418
1418
1419
1419
public baselineCurrentFileBreakpointLocations ( ) {
1420
- let baselineFile = this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ;
1421
- if ( ! baselineFile ) {
1422
- baselineFile = this . activeFile . fileName . replace ( this . basePath + "/breakpointValidation" , "bpSpan" ) ;
1423
- baselineFile = baselineFile . replace ( ts . Extension . Ts , ".baseline" ) ;
1424
-
1425
- }
1420
+ const baselineFile = this . getBaselineFileName ( ) . replace ( this . basePath + "/breakpointValidation" , "bpSpan" ) ;
1426
1421
Harness . Baseline . runBaseline ( baselineFile , this . baselineCurrentFileLocations ( pos => this . getBreakpointStatementLocation ( pos ) ! ) ) ;
1427
1422
}
1428
1423
@@ -1497,8 +1492,7 @@ Actual: ${stringify(fullActual)}`);
1497
1492
}
1498
1493
1499
1494
public baselineQuickInfo ( ) {
1500
- const baselineFile = this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ||
1501
- ts . getBaseFileName ( this . activeFile . fileName ) . replace ( ts . Extension . Ts , ".baseline" ) ;
1495
+ const baselineFile = this . getBaselineFileName ( ) ;
1502
1496
Harness . Baseline . runBaseline (
1503
1497
baselineFile ,
1504
1498
stringify (
@@ -1508,6 +1502,39 @@ Actual: ${stringify(fullActual)}`);
1508
1502
} ) ) ) ) ;
1509
1503
}
1510
1504
1505
+ public baselineSmartSelection ( ) {
1506
+ const n = ts . sys . newLine ;
1507
+ const baselineFile = this . getBaselineFileName ( ) ;
1508
+ const markers = this . getMarkers ( ) ;
1509
+ const fileContent = this . activeFile . content ;
1510
+ const text = markers . map ( marker => {
1511
+ const baselineContent = [ fileContent . slice ( 0 , marker . position ) + "/**/" + fileContent . slice ( marker . position ) + n ] ;
1512
+ let selectionRange : ts . SelectionRange | undefined = this . languageService . getSmartSelectionRange ( this . activeFile . fileName , marker . position ) ;
1513
+ while ( selectionRange ) {
1514
+ const { textSpan } = selectionRange ;
1515
+ let masked = Array . from ( fileContent ) . map ( ( char , index ) => {
1516
+ const charCode = char . charCodeAt ( 0 ) ;
1517
+ if ( index >= textSpan . start && index < ts . textSpanEnd ( textSpan ) ) {
1518
+ return char === " " ? "•" : ts . isLineBreak ( charCode ) ? `↲${ n } ` : char ;
1519
+ }
1520
+ return ts . isLineBreak ( charCode ) ? char : " " ;
1521
+ } ) . join ( "" ) ;
1522
+ masked = masked . replace ( / ^ \s * $ \r ? \n ? / gm, "" ) ; // Remove blank lines
1523
+ const isRealCharacter = ( char : string ) => char !== "•" && char !== "↲" && ! ts . isWhiteSpaceLike ( char . charCodeAt ( 0 ) ) ;
1524
+ const leadingWidth = Array . from ( masked ) . findIndex ( isRealCharacter ) ;
1525
+ const trailingWidth = ts . findLastIndex ( Array . from ( masked ) , isRealCharacter ) ;
1526
+ masked = masked . slice ( 0 , leadingWidth )
1527
+ + masked . slice ( leadingWidth , trailingWidth ) . replace ( / • / g, " " ) . replace ( / ↲ / g, "" )
1528
+ + masked . slice ( trailingWidth ) ;
1529
+ baselineContent . push ( masked ) ;
1530
+ selectionRange = selectionRange . parent ;
1531
+ }
1532
+ return baselineContent . join ( n ) ;
1533
+ } ) . join ( n . repeat ( 2 ) + "=" . repeat ( 80 ) + n . repeat ( 2 ) ) ;
1534
+
1535
+ Harness . Baseline . runBaseline ( baselineFile , text ) ;
1536
+ }
1537
+
1511
1538
public printBreakpointLocation ( pos : number ) {
1512
1539
Harness . IO . log ( "\n**Pos: " + pos + " " + this . spanInfoToString ( this . getBreakpointStatementLocation ( pos ) ! , " " ) ) ;
1513
1540
}
@@ -1562,6 +1589,11 @@ Actual: ${stringify(fullActual)}`);
1562
1589
Harness . IO . log ( stringify ( help . items [ help . selectedItemIndex ] ) ) ;
1563
1590
}
1564
1591
1592
+ private getBaselineFileName ( ) {
1593
+ return this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ||
1594
+ ts . getBaseFileName ( this . activeFile . fileName ) . replace ( ts . Extension . Ts , ".baseline" ) ;
1595
+ }
1596
+
1565
1597
private getSignatureHelp ( { triggerReason } : FourSlashInterface . VerifySignatureHelpOptions ) : ts . SignatureHelpItems | undefined {
1566
1598
return this . languageService . getSignatureHelpItems ( this . activeFile . fileName , this . currentCaretPosition , {
1567
1599
triggerReason
@@ -3973,6 +4005,10 @@ namespace FourSlashInterface {
3973
4005
this . state . baselineQuickInfo ( ) ;
3974
4006
}
3975
4007
4008
+ public baselineSmartSelection ( ) {
4009
+ this . state . baselineSmartSelection ( ) ;
4010
+ }
4011
+
3976
4012
public nameOrDottedNameSpanTextIs ( text : string ) {
3977
4013
this . state . verifyCurrentNameOrDottedNameSpanText ( text ) ;
3978
4014
}
0 commit comments