File tree Expand file tree Collapse file tree 2 files changed +8
-19
lines changed Expand file tree Collapse file tree 2 files changed +8
-19
lines changed Original file line number Diff line number Diff line change @@ -460,17 +460,9 @@ function format(msg: p.RequestMessage): Array<m.Message> {
460
460
} ;
461
461
return [ fakeSuccessResponse , response ] ;
462
462
} else {
463
- // See comment on findBscNativeDirOfFile for why we need
464
- // to recursively search for bsc.exe upward
465
- let bscNativePath = utils . findBscNativeOfFile ( filePath ) ;
466
-
467
463
// code will always be defined here, even though technically it can be undefined
468
464
let code = getOpenedFileContent ( params . textDocument . uri ) ;
469
- let formattedResult = utils . formatCode (
470
- code ,
471
- bscNativePath ,
472
- extension === c . resiExt
473
- ) ;
465
+ let formattedResult = utils . formatCode ( filePath , code ) ;
474
466
if ( formattedResult . kind === "success" ) {
475
467
let max = code . length ;
476
468
let result : p . TextEdit [ ] = [
Original file line number Diff line number Diff line change @@ -93,17 +93,17 @@ type execResult =
93
93
kind : "error" ;
94
94
error : string ;
95
95
} ;
96
- export let formatCode = (
97
- code : string ,
98
- bscNativePath : p . DocumentUri | null ,
99
- isInterface : boolean
100
- ) : execResult => {
101
- let extension = isInterface ? c . resiExt : c . resExt ;
96
+ export let formatCode = ( filePath : string , code : string ) : execResult => {
97
+ let extension = path . extname ( filePath ) ;
102
98
let formatTempFileFullPath = createFileInTempDir ( extension ) ;
103
99
fs . writeFileSync ( formatTempFileFullPath , code , {
104
100
encoding : "utf-8" ,
105
101
} ) ;
106
102
try {
103
+ // See comment on findBscNativeDirOfFile for why we need
104
+ // to recursively search for bsc.exe upward
105
+ let bscNativePath = findBscNativeOfFile ( filePath ) ;
106
+
107
107
// Default to using the project formatter. If not, use the one we ship with
108
108
// the analysis binary in the extension itself.
109
109
if ( bscNativePath != null ) {
@@ -128,10 +128,7 @@ export let formatCode = (
128
128
// sources, probably because of errors. In that case, we bail from
129
129
// formatting by returning the unformatted content.
130
130
if ( result === "" ) {
131
- return {
132
- kind : "success" ,
133
- result : code ,
134
- } ;
131
+ result = code ;
135
132
}
136
133
137
134
return {
You can’t perform that action at this time.
0 commit comments