Skip to content

Commit

Permalink
Drop readDirAsArray / use fs.readdirSync instead
Browse files Browse the repository at this point in the history
  • Loading branch information
ochafik committed Dec 25, 2024
1 parent cde9d90 commit 909e4a8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 0 additions & 4 deletions src/fs/filesystem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions src/language/openscad-completions.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 909e4a8

Please sign in to comment.