@volar/language-server 1.4.0-alpha.1 → 1.4.0-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
+ "use strict";
1
2
  Object.defineProperty(exports, "__esModule", { value: true });
2
3
  exports.sortTsConfigs = exports.createWorkspace = exports.rootTsConfigNames = void 0;
3
- const path = require("typesafe-path");
4
+ const path = require("typesafe-path/posix");
4
5
  const vscode = require("vscode-languageserver");
5
6
  const vscode_uri_1 = require("vscode-uri");
6
7
  const project_1 = require("./project");
@@ -15,7 +16,8 @@ async function createWorkspace(context) {
15
16
  const sys = context.workspaces.fileSystemHost?.getWorkspaceFileSystem(context.rootUri);
16
17
  const documentRegistry = sys ? context.workspaces.ts?.createDocumentRegistry(sys.useCaseSensitiveFileNames, uriToFileName(context.rootUri.toString())) : undefined;
17
18
  const projects = (0, uriMap_1.createUriMap)(fileNameToUri);
18
- const rootTsConfigs = new Set(sys?.readDirectory(uriToFileName(context.rootUri.toString()), exports.rootTsConfigNames, undefined, ['**/*']).map(fileName => fileName.replace(/\\/g, '/')));
19
+ const rootTsConfigs = new Set();
20
+ const searchedDirs = new Set();
19
21
  const disposeTsConfigWatch = context.workspaces.fileSystemHost?.onDidChangeWatchedFiles(({ changes }) => {
20
22
  for (const change of changes) {
21
23
  if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
@@ -83,6 +85,21 @@ async function createWorkspace(context) {
83
85
  return inferredProject;
84
86
  }
85
87
  async function findMatchConfigs(uri) {
88
+ const filePath = uriToFileName(uri.toString());
89
+ let dir = path.dirname(filePath);
90
+ while (true) {
91
+ if (searchedDirs.has(dir)) {
92
+ break;
93
+ }
94
+ searchedDirs.add(dir);
95
+ for (const tsConfigName of exports.rootTsConfigNames) {
96
+ const tsconfigPath = path.join(dir, tsConfigName);
97
+ if (sys?.fileExists(tsconfigPath)) {
98
+ rootTsConfigs.add(tsconfigPath);
99
+ }
100
+ }
101
+ dir = path.dirname(dir);
102
+ }
86
103
  await prepareClosestootParsedCommandLine();
87
104
  return await findDirectIncludeTsconfig() ?? await findIndirectReferenceTsconfig();
88
105
  async function prepareClosestootParsedCommandLine() {
@@ -142,7 +159,7 @@ async function createWorkspace(context) {
142
159
  if (parsedCommandLine.projectReferences?.length) {
143
160
  const newChains = [];
144
161
  for (const projectReference of parsedCommandLine.projectReferences) {
145
- let tsConfigPath = projectReference.path;
162
+ let tsConfigPath = projectReference.path.replace(/\\/g, '/');
146
163
  // fix https://github.com/johnsoncodehk/volar/issues/712
147
164
  if (sys && !sys.fileExists(tsConfigPath)) {
148
165
  const newTsConfigPath = path.join(tsConfigPath, 'tsconfig.json');