@@ -2201,68 +2201,36 @@ namespace ts.server {
22012201 } ) ;
22022202 }
22032203
2204- private toggleLineComment ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2204+ private toggleLineComment ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
22052205 const { file, project } = this . getFileAndProject ( args ) ;
22062206 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
22072207 const textRange = this . getRange ( args , scriptInfo ) ;
22082208
2209- const textChanges = project . getLanguageService ( ) . toggleLineComment ( file , textRange ) ;
2210-
2211- if ( simplifiedResult ) {
2212- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2213-
2214- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2215- }
2216-
2217- return textChanges ;
2209+ return project . getLanguageService ( ) . toggleLineComment ( file , textRange ) ;
22182210 }
22192211
2220- private toggleMultilineComment ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2212+ private toggleMultilineComment ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
22212213 const { file, project } = this . getFileAndProject ( args ) ;
22222214 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
22232215 const textRange = this . getRange ( args , scriptInfo ) ;
22242216
2225- const textChanges = project . getLanguageService ( ) . toggleMultilineComment ( file , textRange ) ;
2226-
2227- if ( simplifiedResult ) {
2228- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2229-
2230- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2231- }
2232-
2233- return textChanges ;
2217+ return project . getLanguageService ( ) . toggleMultilineComment ( file , textRange ) ;
22342218 }
22352219
2236- private commentSelection ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2220+ private commentSelection ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
22372221 const { file, project } = this . getFileAndProject ( args ) ;
22382222 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
22392223 const textRange = this . getRange ( args , scriptInfo ) ;
22402224
2241- const textChanges = project . getLanguageService ( ) . commentSelection ( file , textRange ) ;
2242-
2243- if ( simplifiedResult ) {
2244- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2245-
2246- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2247- }
2248-
2249- return textChanges ;
2225+ return project . getLanguageService ( ) . commentSelection ( file , textRange ) ;
22502226 }
22512227
2252- private uncommentSelection ( args : protocol . FileRangeRequestArgs , simplifiedResult : boolean ) : TextChange [ ] | protocol . CodeEdit [ ] {
2228+ private uncommentSelection ( args : protocol . FileRangeRequestArgs ) : TextChange [ ] {
22532229 const { file, project } = this . getFileAndProject ( args ) ;
22542230 const scriptInfo = project . getScriptInfoForNormalizedPath ( file ) ! ;
22552231 const textRange = this . getRange ( args , scriptInfo ) ;
22562232
2257- const textChanges = project . getLanguageService ( ) . uncommentSelection ( file , textRange ) ;
2258-
2259- if ( simplifiedResult ) {
2260- const scriptInfo = this . projectService . getScriptInfoForNormalizedPath ( file ) ! ;
2261-
2262- return textChanges . map ( textChange => this . convertTextChangeToCodeEdit ( textChange , scriptInfo ) ) ;
2263- }
2264-
2265- return textChanges ;
2233+ return project . getLanguageService ( ) . uncommentSelection ( file , textRange ) ;
22662234 }
22672235
22682236 private mapSelectionRange ( selectionRange : SelectionRange , scriptInfo : ScriptInfo ) : protocol . SelectionRange {
@@ -2710,29 +2678,17 @@ namespace ts.server {
27102678 [ CommandNames . ProvideCallHierarchyOutgoingCalls ] : ( request : protocol . ProvideCallHierarchyOutgoingCallsRequest ) => {
27112679 return this . requiredResponse ( this . provideCallHierarchyOutgoingCalls ( request . arguments ) ) ;
27122680 } ,
2713- [ CommandNames . ToggleLineComment ] : ( request : protocol . ToggleLineCommentRequest ) => {
2714- return this . requiredResponse ( this . toggleLineComment ( request . arguments , /*simplifiedResult*/ true ) ) ;
2715- } ,
2716- [ CommandNames . ToggleLineCommentFull ] : ( request : protocol . ToggleLineCommentRequest ) => {
2717- return this . requiredResponse ( this . toggleLineComment ( request . arguments , /*simplifiedResult*/ false ) ) ;
2681+ [ CommandNames . ToggleLineCommentFull ] : ( request : protocol . CommentSelectionRequest ) => {
2682+ return this . requiredResponse ( this . toggleLineComment ( request . arguments ) ) ;
27182683 } ,
2719- [ CommandNames . ToggleMultilineComment ] : ( request : protocol . ToggleMultilineCommentRequest ) => {
2720- return this . requiredResponse ( this . toggleMultilineComment ( request . arguments , /*simplifiedResult*/ true ) ) ;
2721- } ,
2722- [ CommandNames . ToggleMultilineCommentFull ] : ( request : protocol . ToggleMultilineCommentRequest ) => {
2723- return this . requiredResponse ( this . toggleMultilineComment ( request . arguments , /*simplifiedResult*/ false ) ) ;
2724- } ,
2725- [ CommandNames . CommentSelection ] : ( request : protocol . CommentSelectionRequest ) => {
2726- return this . requiredResponse ( this . commentSelection ( request . arguments , /*simplifiedResult*/ true ) ) ;
2684+ [ CommandNames . ToggleMultilineCommentFull ] : ( request : protocol . CommentSelectionRequest ) => {
2685+ return this . requiredResponse ( this . toggleMultilineComment ( request . arguments ) ) ;
27272686 } ,
27282687 [ CommandNames . CommentSelectionFull ] : ( request : protocol . CommentSelectionRequest ) => {
2729- return this . requiredResponse ( this . commentSelection ( request . arguments , /*simplifiedResult*/ false ) ) ;
2730- } ,
2731- [ CommandNames . UncommentSelection ] : ( request : protocol . UncommentSelectionRequest ) => {
2732- return this . requiredResponse ( this . uncommentSelection ( request . arguments , /*simplifiedResult*/ true ) ) ;
2688+ return this . requiredResponse ( this . commentSelection ( request . arguments ) ) ;
27332689 } ,
2734- [ CommandNames . UncommentSelectionFull ] : ( request : protocol . UncommentSelectionRequest ) => {
2735- return this . requiredResponse ( this . uncommentSelection ( request . arguments , /*simplifiedResult*/ false ) ) ;
2690+ [ CommandNames . UncommentSelectionFull ] : ( request : protocol . CommentSelectionRequest ) => {
2691+ return this . requiredResponse ( this . uncommentSelection ( request . arguments ) ) ;
27362692 } ,
27372693 } ) ;
27382694
0 commit comments