@@ -1159,7 +1159,11 @@ protected async Task HandleDocumentFormattingRequest(
11591159 DocumentFormattingParams formattingParams ,
11601160 RequestContext < TextEdit [ ] > requestContext )
11611161 {
1162- var result = await Format ( formattingParams . TextDocument . Uri , null ) ;
1162+ var result = await Format (
1163+ formattingParams . TextDocument . Uri ,
1164+ formattingParams . options ,
1165+ null ) ;
1166+
11631167 await requestContext . SendResult ( new TextEdit [ 1 ]
11641168 {
11651169 new TextEdit
@@ -1174,7 +1178,11 @@ protected async Task HandleDocumentRangeFormattingRequest(
11741178 DocumentRangeFormattingParams formattingParams ,
11751179 RequestContext < TextEdit [ ] > requestContext )
11761180 {
1177- var result = await Format ( formattingParams . TextDocument . Uri , formattingParams . Range ) ;
1181+ var result = await Format (
1182+ formattingParams . TextDocument . Uri ,
1183+ formattingParams . options ,
1184+ formattingParams . Range ) ;
1185+
11781186 await requestContext . SendResult ( new TextEdit [ 1 ]
11791187 {
11801188 new TextEdit
@@ -1191,20 +1199,23 @@ await requestContext.SendResult(new TextEdit[1]
11911199
11921200 private async Task < Tuple < string , Range > > Format (
11931201 string documentUri ,
1202+ FormattingOptions options ,
11941203 Range range )
11951204 {
11961205
11971206 // TODO Get settings
11981207 // TODO Update settings to store code formatting settings
11991208 var scriptFile = editorSession . Workspace . GetFile ( documentUri ) ;
1209+ var pssaSettings = currentSettings . CodeFormatting . GetPSSASettingsHashTable (
1210+ options . TabSize ,
1211+ options . InsertSpaces ) ;
12001212
12011213 // TODO raise an error event incase format returns null;
12021214 string formattedScript ;
12031215 Range editRange ;
12041216 int sl , sc , el , ec ;
12051217 if ( range == null )
12061218 {
1207- formattedScript = await editorSession . AnalysisService . Format ( scriptFile . Contents ) ;
12081219 sl = - 1 ;
12091220 sc = - 1 ;
12101221 el = - 1 ;
@@ -1235,7 +1246,13 @@ private async Task<Tuple<string, Range>> Format(
12351246 }
12361247 } ;
12371248
1238- formattedScript = await editorSession . AnalysisService . Format ( scriptFile . Contents , sl , sc , el , ec ) ;
1249+ formattedScript = await editorSession . AnalysisService . Format (
1250+ scriptFile . Contents ,
1251+ pssaSettings ,
1252+ sl ,
1253+ sc ,
1254+ el ,
1255+ ec ) ;
12391256 formattedScript = formattedScript ?? scriptFile . Contents ;
12401257 return Tuple . Create ( formattedScript , editRange ) ;
12411258 }
0 commit comments