@@ -21,13 +21,15 @@ internal sealed class PrettierCommand : BaseCommand
2121 private ITextBufferUndoManager _undoManager ;
2222 private NodeProcess _node ;
2323 private Encoding _encoding ;
24+ private string _filePath ;
2425
25- public PrettierCommand ( IWpfTextView view , ITextBufferUndoManager undoManager , NodeProcess node , Encoding encoding )
26+ public PrettierCommand ( IWpfTextView view , ITextBufferUndoManager undoManager , NodeProcess node , Encoding encoding , string filePath )
2627 {
2728 _view = view ;
2829 _undoManager = undoManager ;
2930 _node = node ;
3031 _encoding = encoding ;
32+ _filePath = filePath ;
3133 }
3234
3335 public override int Exec ( ref Guid pguidCmdGroup , uint nCmdID , uint nCmdexecopt , IntPtr pvaIn , IntPtr pvaOut )
@@ -48,7 +50,7 @@ public override int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt,
4850 private async Task < bool > MakePrettier ( )
4951 {
5052 string input = _view . TextBuffer . CurrentSnapshot . GetText ( ) ;
51- string output = await _node . ExecuteProcess ( input , _encoding ) ;
53+ string output = await _node . ExecuteProcess ( input , _encoding , _filePath ) ;
5254
5355 if ( string . IsNullOrEmpty ( output ) || input == output )
5456 return false ;
@@ -58,10 +60,7 @@ private async Task<bool> MakePrettier()
5860 {
5961 edit . Replace ( 0 , _view . TextBuffer . CurrentSnapshot . Length , output ) ;
6062 edit . Apply ( ) ;
61-
62- var dte = ( DTE ) ServiceProvider . GlobalProvider . GetService ( typeof ( DTE ) ) ;
63- dte . ExecuteCommand ( "Edit.FormatDocument" ) ;
64-
63+
6564 undo . Complete ( ) ;
6665 }
6766
0 commit comments