@@ -48,7 +48,7 @@ export let findProjectRootOfFile = (
48
48
// Also, if someone's ever formatting a regular project setup's dependency
49
49
// (which is weird but whatever), they'll at least find an upward bs-platform
50
50
// from the dependent.
51
- export let findBscNativeOfFile = (
51
+ export let findBscBinaryFromProjectRoot = (
52
52
source : p . DocumentUri
53
53
) : null | p . DocumentUri => {
54
54
let dir = path . dirname ( source ) ;
@@ -66,17 +66,14 @@ export let findBscNativeOfFile = (
66
66
// reached the top
67
67
return null ;
68
68
} else {
69
- return findBscNativeOfFile ( dir ) ;
69
+ return findBscBinaryFromProjectRoot ( dir ) ;
70
70
}
71
71
} ;
72
72
73
- let findBscBinFromConfig = (
74
- pathToBinFromConfig : p . DocumentUri | null
73
+ export let findBscBinaryFromConfig = (
74
+ pathToBinaryDirFromConfig : p . DocumentUri
75
75
) : null | p . DocumentUri => {
76
- if ( pathToBinFromConfig === null ) {
77
- return null ;
78
- }
79
- let bscPath = path . join ( pathToBinFromConfig , c . bscBinName ) ;
76
+ let bscPath = path . join ( pathToBinaryDirFromConfig , c . bscBinName ) ;
80
77
if ( fs . existsSync ( bscPath ) ) {
81
78
return bscPath ;
82
79
}
@@ -124,7 +121,7 @@ type execResult =
124
121
} ;
125
122
126
123
export let formatCode = (
127
- pathToBinFromConfig : p . DocumentUri | null ,
124
+ bscPath : p . DocumentUri | null ,
128
125
filePath : string ,
129
126
code : string
130
127
) : execResult => {
@@ -134,15 +131,7 @@ export let formatCode = (
134
131
encoding : "utf-8" ,
135
132
} ) ;
136
133
try {
137
- // Try to find the bsc bin from the binaryPath setting from the configuration.
138
- let bscPath = findBscBinFromConfig ( pathToBinFromConfig ) ;
139
-
140
- // See comment on findBscNativeDirOfFile for why we need
141
- // to recursively search for bsc.exe upward
142
- bscPath = bscPath == null ? findBscNativeOfFile ( filePath ) : bscPath ;
143
-
144
- // Default to using the formatter from the binaryPath setting from the configuration
145
- // or the project formatter.
134
+ // It will try to use the user formatting binary.
146
135
// If not, use the one we ship with the analysis binary in the extension itself.
147
136
if ( bscPath != null ) {
148
137
let result = childProcess . execFileSync ( bscPath , [
0 commit comments