Drop readDirAsArray / use fs.readdirSync instead

This commit is contained in:
ochafik 2024-12-25 01:45:11 +00:00 committed by Olivier Chafik
commit 909e4a8231
2 changed files with 3 additions and 6 deletions

View file

@ -15,10 +15,6 @@ export const getParentDir = (path: string) => {
return d === '' ? (path.startsWith('/') ? '/' : '.') : d;
}
export function readDirAsArray(fs: FS, path: string): Promise<string[] | undefined> {
return new Promise((res, rej) => fs.readdir(path, (err, files) => err ? rej(err) : res(files)));
}
export function join(a: string, b: string): string {
if (a === '.') return b;
if (a.endsWith('/')) return join(a.substring(0, a.length - 1), b);

View file

@ -1,7 +1,7 @@
// Portions of this file are Copyright 2021 Google LLC, and licensed under GPL2+. See COPYING.
import * as monaco from 'monaco-editor/esm/vs/editor/editor.api';
import { join, readDirAsArray, Symlinks } from '../fs/filesystem';
import { join, Symlinks } from '../fs/filesystem';
import { ParsedFile, ParsedFunctionoidDef, parseOpenSCAD, stripComments } from './openscad-pseudoparser';
import builtinSignatures from './openscad-builtins'
import { mapObject } from '../utils';
@ -192,7 +192,8 @@ export async function buildOpenSCADCompletionItemProvider(fs: FS, workingDir: st
for (const folder of [join('/libraries', folderName), join(workingDir, folderName)]) {
files = folderPrefix == '' ? [...Object.keys(allSymlinks)] : [];
try {
files = [...(await readDirAsArray(fs, folder) ?? []), ...files];
files = [...(fs.readdirSync(folder) ?? []), ...files];
// files = [...(await readDirAsArray(fs, folder) ?? []), ...files];
// console.log('readDir', folder, files);
break;
} catch (e) {