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

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,6 @@
1
1
  Object.defineProperty(exports, "__esModule", { value: true });
2
2
  exports.sortTsConfigs = exports.createWorkspace = exports.rootTsConfigNames = void 0;
3
- const path = require("typesafe-path");
3
+ const path = require("typesafe-path/posix");
4
4
  const vscode = require("vscode-languageserver");
5
5
  const vscode_uri_1 = require("vscode-uri");
6
6
  const project_1 = require("./project");
@@ -15,7 +15,8 @@ async function createWorkspace(context) {
15
15
  const sys = context.workspaces.fileSystemHost?.getWorkspaceFileSystem(context.rootUri);
16
16
  const documentRegistry = sys ? context.workspaces.ts?.createDocumentRegistry(sys.useCaseSensitiveFileNames, uriToFileName(context.rootUri.toString())) : undefined;
17
17
  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, '/')));
18
+ const rootTsConfigs = new Set();
19
+ const searchedDirs = new Set();
19
20
  const disposeTsConfigWatch = context.workspaces.fileSystemHost?.onDidChangeWatchedFiles(({ changes }) => {
20
21
  for (const change of changes) {
21
22
  if (exports.rootTsConfigNames.includes(change.uri.substring(change.uri.lastIndexOf('/') + 1))) {
@@ -83,6 +84,24 @@ async function createWorkspace(context) {
83
84
  return inferredProject;
84
85
  }
85
86
  async function findMatchConfigs(uri) {
87
+ const filePath = uriToFileName(uri.toString());
88
+ let dir = path.dirname(filePath);
89
+ while (true) {
90
+ if (searchedDirs.has(dir)) {
91
+ break;
92
+ }
93
+ searchedDirs.add(dir);
94
+ const tsconfigPaths = [
95
+ path.join(dir, 'tsconfig.json'),
96
+ path.join(dir, 'jsconfig.json'),
97
+ ];
98
+ for (const tsconfigPath of tsconfigPaths) {
99
+ if (sys?.fileExists(tsconfigPath)) {
100
+ rootTsConfigs.add(tsconfigPath);
101
+ }
102
+ }
103
+ dir = path.dirname(dir);
104
+ }
86
105
  await prepareClosestootParsedCommandLine();
87
106
  return await findDirectIncludeTsconfig() ?? await findIndirectReferenceTsconfig();
88
107
  async function prepareClosestootParsedCommandLine() {
@@ -142,7 +161,7 @@ async function createWorkspace(context) {
142
161
  if (parsedCommandLine.projectReferences?.length) {
143
162
  const newChains = [];
144
163
  for (const projectReference of parsedCommandLine.projectReferences) {
145
- let tsConfigPath = projectReference.path;
164
+ let tsConfigPath = projectReference.path.replace(/\\/g, '/');
146
165
  // fix https://github.com/johnsoncodehk/volar/issues/712
147
166
  if (sys && !sys.fileExists(tsConfigPath)) {
148
167
  const newTsConfigPath = path.join(tsConfigPath, 'tsconfig.json');