@@ -741,10 +741,30 @@ function format(msg: p.RequestMessage): Array<p.Message> {
741
741
let bscBinaryPath =
742
742
projectRootPath === null ? null : findBscBinary ( projectRootPath ) ;
743
743
744
- if (
745
- bscBinaryPath == null &&
746
- ! extensionConfiguration . allowBuiltInFormatter
747
- ) {
744
+ let formattedResult = utils . formatCode (
745
+ bscBinaryPath ,
746
+ filePath ,
747
+ code ,
748
+ extensionConfiguration . allowBuiltInFormatter
749
+ ) ;
750
+ if ( formattedResult . kind === "success" ) {
751
+ let max = code . length ;
752
+ let result : p . TextEdit [ ] = [
753
+ {
754
+ range : {
755
+ start : { line : 0 , character : 0 } ,
756
+ end : { line : max , character : max } ,
757
+ } ,
758
+ newText : formattedResult . result ,
759
+ } ,
760
+ ] ;
761
+ let response : p . ResponseMessage = {
762
+ jsonrpc : c . jsonrpcVersion ,
763
+ id : msg . id ,
764
+ result : result ,
765
+ } ;
766
+ return [ response ] ;
767
+ } else if ( formattedResult . kind === "blocked-using-built-in-formatter" ) {
748
768
// Let's only prompt the user once about this, or things might become annoying.
749
769
if ( hasPromptedAboutBuiltInFormatter ) {
750
770
return [ fakeSuccessResponse ] ;
@@ -763,26 +783,6 @@ function format(msg: p.RequestMessage): Array<p.Message> {
763
783
params : params ,
764
784
} ;
765
785
return [ fakeSuccessResponse , response ] ;
766
- }
767
-
768
- let formattedResult = utils . formatCode ( bscBinaryPath , filePath , code ) ;
769
- if ( formattedResult . kind === "success" ) {
770
- let max = code . length ;
771
- let result : p . TextEdit [ ] = [
772
- {
773
- range : {
774
- start : { line : 0 , character : 0 } ,
775
- end : { line : max , character : max } ,
776
- } ,
777
- newText : formattedResult . result ,
778
- } ,
779
- ] ;
780
- let response : p . ResponseMessage = {
781
- jsonrpc : c . jsonrpcVersion ,
782
- id : msg . id ,
783
- result : result ,
784
- } ;
785
- return [ response ] ;
786
786
} else {
787
787
// let the diagnostics logic display the updated syntax errors,
788
788
// from the build.
0 commit comments