Skip to content

Commit

Permalink
Small LSP bugfixes (#9382)
Browse files Browse the repository at this point in the history
  • Loading branch information
mischnic authored Nov 14, 2023
1 parent c88116a commit 7959891
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions packages/reporters/lsp-reporter/src/LspReporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async function watchLspActive(): Promise<FSWatcher> {
});
}

async function doWatchStart() {
async function doWatchStart(options) {
await fs.promises.mkdir(BASEDIR, {recursive: true});

// For each existing file, check if the pid matches a running process.
Expand Down Expand Up @@ -141,7 +141,7 @@ async function doWatchStart() {
await fs.promises.writeFile(
META_FILE,
JSON.stringify({
projectRoot: process.cwd(),
projectRoot: options.projectRoot,
pid: process.pid,
argv: process.argv,
}),
Expand All @@ -158,7 +158,7 @@ export default (new Reporter({

if (watchStarted && lspStarted) {
if (!watchStartPromise) {
watchStartPromise = doWatchStart();
watchStartPromise = doWatchStart(options);
}
await watchStartPromise;
}
Expand Down
7 changes: 3 additions & 4 deletions packages/utils/parcel-lsp/src/LspServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function findClient(document: DocumentUri): Client | undefined {
return bestClient;
}

function parseMetafile(filepath: string) {
function loadMetafile(filepath: string) {
const file = fs.readFileSync(filepath, 'utf-8');
return JSON.parse(file);
}
Expand Down Expand Up @@ -295,7 +295,7 @@ fs.writeFileSync(path.join(BASEDIR, LSP_SENTINEL_FILENAME), '');
for (let filename of fs.readdirSync(BASEDIR)) {
if (!filename.endsWith('.json')) continue;
let filepath = path.join(BASEDIR, filename);
const contents = parseMetafile(filepath);
const contents = loadMetafile(filepath);
const {projectRoot} = contents;

if (WORKSPACE_ROOT === projectRoot) {
Expand All @@ -312,8 +312,7 @@ watcher.subscribe(BASEDIR, async (err, events) => {

for (let event of events) {
if (event.type === 'create' && event.path.endsWith('.json')) {
const file = fs.readFileSync(event.path, 'utf-8');
const contents = parseMetafile(file);
const contents = loadMetafile(event.path);
const {projectRoot} = contents;

if (WORKSPACE_ROOT === projectRoot) {
Expand Down

0 comments on commit 7959891

Please sign in to comment.