@@ -1159,7 +1159,11 @@ protected async Task HandleDocumentFormattingRequest(
1159
1159
DocumentFormattingParams formattingParams ,
1160
1160
RequestContext < TextEdit [ ] > requestContext )
1161
1161
{
1162
- var result = await Format ( formattingParams . TextDocument . Uri , null ) ;
1162
+ var result = await Format (
1163
+ formattingParams . TextDocument . Uri ,
1164
+ formattingParams . options ,
1165
+ null ) ;
1166
+
1163
1167
await requestContext . SendResult ( new TextEdit [ 1 ]
1164
1168
{
1165
1169
new TextEdit
@@ -1174,7 +1178,11 @@ protected async Task HandleDocumentRangeFormattingRequest(
1174
1178
DocumentRangeFormattingParams formattingParams ,
1175
1179
RequestContext < TextEdit [ ] > requestContext )
1176
1180
{
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
+
1178
1186
await requestContext . SendResult ( new TextEdit [ 1 ]
1179
1187
{
1180
1188
new TextEdit
@@ -1191,20 +1199,23 @@ await requestContext.SendResult(new TextEdit[1]
1191
1199
1192
1200
private async Task < Tuple < string , Range > > Format (
1193
1201
string documentUri ,
1202
+ FormattingOptions options ,
1194
1203
Range range )
1195
1204
{
1196
1205
1197
1206
// TODO Get settings
1198
1207
// TODO Update settings to store code formatting settings
1199
1208
var scriptFile = editorSession . Workspace . GetFile ( documentUri ) ;
1209
+ var pssaSettings = currentSettings . CodeFormatting . GetPSSASettingsHashTable (
1210
+ options . TabSize ,
1211
+ options . InsertSpaces ) ;
1200
1212
1201
1213
// TODO raise an error event incase format returns null;
1202
1214
string formattedScript ;
1203
1215
Range editRange ;
1204
1216
int sl , sc , el , ec ;
1205
1217
if ( range == null )
1206
1218
{
1207
- formattedScript = await editorSession . AnalysisService . Format ( scriptFile . Contents ) ;
1208
1219
sl = - 1 ;
1209
1220
sc = - 1 ;
1210
1221
el = - 1 ;
@@ -1235,7 +1246,13 @@ private async Task<Tuple<string, Range>> Format(
1235
1246
}
1236
1247
} ;
1237
1248
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 ) ;
1239
1256
formattedScript = formattedScript ?? scriptFile . Contents ;
1240
1257
return Tuple . Create ( formattedScript , editRange ) ;
1241
1258
}
0 commit comments