@@ -139,6 +139,7 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
139
139
private readonly ruleOrder : string [ ] = [
140
140
"PSPlaceCloseBrace" ,
141
141
"PSPlaceOpenBrace" ,
142
+ "PSUseConsistentWhitespace" ,
142
143
"PSUseConsistentIndentation" ] ;
143
144
144
145
// Allows edits to be undone and redone is a single step.
@@ -232,12 +233,13 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
232
233
} ) ;
233
234
234
235
// We cannot handle multiple edits at the same point hence we
235
- // filter the markers so that there is only one edit per line
236
- // This ideally should not happen but it is good to have some additional safeguard
236
+ // filter the markers so that there is only one edit per region
237
237
if ( edits . length > 0 ) {
238
238
uniqueEdits . push ( edits [ 0 ] ) ;
239
239
for ( let edit of edits . slice ( 1 ) ) {
240
- if ( editComparer ( uniqueEdits [ uniqueEdits . length - 1 ] , edit ) !== 0 ) {
240
+ let lastEdit : ScriptRegion = uniqueEdits [ uniqueEdits . length - 1 ] ;
241
+ if ( lastEdit . startLineNumber !== edit . startLineNumber
242
+ || ( edit . startColumnNumber + edit . text . length ) < lastEdit . startColumnNumber ) {
241
243
uniqueEdits . push ( edit ) ;
242
244
}
243
245
}
@@ -332,6 +334,13 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
332
334
ruleSettings [ "IndentationSize" ] = vscode . workspace . getConfiguration ( "editor" ) . get < number > ( "tabSize" ) ;
333
335
break ;
334
336
337
+ case "PSUseConsistentWhitespace" :
338
+ ruleSettings [ "CheckOpenBrace" ] = psSettings . codeFormatting . whitespaceBeforeOpenBrace ;
339
+ ruleSettings [ "CheckOpenParen" ] = psSettings . codeFormatting . whitespaceBeforeOpenParen ;
340
+ ruleSettings [ "CheckOperator" ] = psSettings . codeFormatting . whitespaceAroundOperator ;
341
+ ruleSettings [ "CheckSeparator" ] = psSettings . codeFormatting . whitespaceAfterSeparator ;
342
+ break ;
343
+
335
344
default :
336
345
break ;
337
346
}
0 commit comments