This repository was archived by the owner on Jan 2, 2026. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +7
-5
lines changed
Expand file tree Collapse file tree 1 file changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -12,18 +12,19 @@ const wholeDocumentRange = new vscode.Range(
1212 Number . MAX_SAFE_INTEGER ,
1313) ;
1414
15+ function rootPathForDocument ( document : vscode . TextDocument ) : string {
16+ const workspaceFolder = vscode . workspace . getWorkspaceFolder ( document . uri ) ;
17+ return ( workspaceFolder && workspaceFolder . uri . fsPath ) || vscode . workspace . rootPath || "./" ;
18+ }
19+
1520function userDefinedFormatOptionsForDocument ( document : vscode . TextDocument ) : {
1621 options : string [ ] ;
1722 hasConfig : boolean ;
1823} {
1924 const formatOptions = Current . config . formatOptions ( ) ;
2025 if ( formatOptions . indexOf ( "--config" ) != - 1 )
2126 return { options : formatOptions , hasConfig : true } ;
22- const workspaceFolder = vscode . workspace . getWorkspaceFolder ( document . uri ) ;
23- const rootPath =
24- ( workspaceFolder && workspaceFolder . uri . fsPath ) ||
25- vscode . workspace . rootPath ||
26- "./" ;
27+ const rootPath = rootPathForDocument ( document ) ;
2728 const searchPaths = Current . config
2829 . formatConfigSearchPaths ( )
2930 . map ( ( current ) => resolve ( rootPath , current ) ) ;
@@ -85,6 +86,7 @@ function format(request: {
8586 ] ,
8687 {
8788 encoding : "utf8" ,
89+ cwd : rootPathForDocument ( request . document ) ,
8890 input,
8991 } ,
9092 ) ;
You can’t perform that action at this time.
0 commit comments