@@ -1417,12 +1417,7 @@ Actual: ${stringify(fullActual)}`);
14171417 }
14181418
14191419 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 ( "breakpointValidation" , "bpSpan" ) ;
14261421 Harness . Baseline . runBaseline ( baselineFile , this . baselineCurrentFileLocations ( pos => this . getBreakpointStatementLocation ( pos ) ! ) ) ;
14271422 }
14281423
@@ -1497,8 +1492,7 @@ Actual: ${stringify(fullActual)}`);
14971492 }
14981493
14991494 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 ( ) ;
15021496 Harness . Baseline . runBaseline (
15031497 baselineFile ,
15041498 stringify (
@@ -1508,6 +1502,39 @@ Actual: ${stringify(fullActual)}`);
15081502 } ) ) ) ) ;
15091503 }
15101504
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 ( fileContent . includes ( "\n" ) ? n + n : n ) ;
1533+ } ) . join ( n . repeat ( 2 ) + "=" . repeat ( 80 ) + n . repeat ( 2 ) ) ;
1534+
1535+ Harness . Baseline . runBaseline ( baselineFile , text ) ;
1536+ }
1537+
15111538 public printBreakpointLocation ( pos : number ) {
15121539 Harness . IO . log ( "\n**Pos: " + pos + " " + this . spanInfoToString ( this . getBreakpointStatementLocation ( pos ) ! , " " ) ) ;
15131540 }
@@ -1562,6 +1589,11 @@ Actual: ${stringify(fullActual)}`);
15621589 Harness . IO . log ( stringify ( help . items [ help . selectedItemIndex ] ) ) ;
15631590 }
15641591
1592+ private getBaselineFileName ( ) {
1593+ return this . testData . globalOptions [ MetadataOptionNames . baselineFile ] ||
1594+ ts . getBaseFileName ( this . activeFile . fileName ) . replace ( ts . Extension . Ts , ".baseline" ) ;
1595+ }
1596+
15651597 private getSignatureHelp ( { triggerReason } : FourSlashInterface . VerifySignatureHelpOptions ) : ts . SignatureHelpItems | undefined {
15661598 return this . languageService . getSignatureHelpItems ( this . activeFile . fileName , this . currentCaretPosition , {
15671599 triggerReason
@@ -3960,6 +3992,10 @@ namespace FourSlashInterface {
39603992 this . state . baselineQuickInfo ( ) ;
39613993 }
39623994
3995+ public baselineSmartSelection ( ) {
3996+ this . state . baselineSmartSelection ( ) ;
3997+ }
3998+
39633999 public nameOrDottedNameSpanTextIs ( text : string ) {
39644000 this . state . verifyCurrentNameOrDottedNameSpanText ( text ) ;
39654001 }
0 commit comments