@@ -139,6 +139,7 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
139139 private readonly ruleOrder : string [ ] = [
140140 "PSPlaceCloseBrace" ,
141141 "PSPlaceOpenBrace" ,
142+ "PSUseConsistentWhitespace" ,
142143 "PSUseConsistentIndentation" ] ;
143144
144145 // Allows edits to be undone and redone is a single step.
@@ -232,12 +233,13 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
232233 } ) ;
233234
234235 // 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
237237 if ( edits . length > 0 ) {
238238 uniqueEdits . push ( edits [ 0 ] ) ;
239239 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 ) {
241243 uniqueEdits . push ( edit ) ;
242244 }
243245 }
@@ -332,6 +334,13 @@ class PSDocumentFormattingEditProvider implements DocumentFormattingEditProvider
332334 ruleSettings [ "IndentationSize" ] = vscode . workspace . getConfiguration ( "editor" ) . get < number > ( "tabSize" ) ;
333335 break ;
334336
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+
335344 default :
336345 break ;
337346 }
0 commit comments