From b7f59b65ac3daed3930f89a3540c8c34f1515dd0 Mon Sep 17 00:00:00 2001 From: bunsenstraat Date: Tue, 4 Jul 2023 13:54:52 +0200 Subject: [PATCH] fix glob --- apps/remix-ide/src/app/files/fileManager.ts | 4 ++++ .../app/plugins/parser/services/code-parser-imports.ts | 2 -- apps/remixdesktop/src/plugins/fsPlugin.ts | 9 ++++++--- .../search/src/lib/components/results/ResultItem.tsx | 1 - libs/remix-ui/search/src/lib/context/context.tsx | 2 -- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 3bab6b2725..e8df1f79d8 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -858,6 +858,10 @@ class FileManager extends Plugin { } currentWorkspace() { + if(isElectron()){ + return '' + } + if (this.mode !== 'localhost') { const file = this.currentFile() || '' const provider = this.fileProviderOf(file) diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts index ab3b4965e3..1af4591ba1 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-imports.ts @@ -42,7 +42,6 @@ export default class CodeParserImports { if (isElectron()) { const files = await this.plugin.call('fs', 'glob', '/', '**/*.sol') - console.log('GLOB', '/', files) // only get path property of files this.data.files = files.map(x => x.path) @@ -53,7 +52,6 @@ export default class CodeParserImports { } - console.log('setFileTree', this.data.files) } getDirectory = async (dir: string) => { diff --git a/apps/remixdesktop/src/plugins/fsPlugin.ts b/apps/remixdesktop/src/plugins/fsPlugin.ts index 423d2fa869..391b3f9b7e 100644 --- a/apps/remixdesktop/src/plugins/fsPlugin.ts +++ b/apps/remixdesktop/src/plugins/fsPlugin.ts @@ -126,11 +126,12 @@ class FSPluginClient extends ElectronBasePluginClient { async glob(path: string, pattern: string, options?: GlobOptions): Promise { - path = this.fixPath(path) + path = convertPathToPosix(this.fixPath(path)) const files = await glob(path + pattern, { withFileTypes: true, ...options }) + const result: any[] = [] for (const file of files) { @@ -141,6 +142,9 @@ class FSPluginClient extends ElectronBasePluginClient { if (pathWithoutWorkingDir.startsWith('/')) { pathWithoutWorkingDir = pathWithoutWorkingDir.slice(1) } + if(pathWithoutWorkingDir.startsWith('\\')) { + pathWithoutWorkingDir = pathWithoutWorkingDir.slice(1) + } result.push({ path: pathWithoutWorkingDir + (file as Path).name, isDirectory: (file as Path).isDirectory(), @@ -225,11 +229,11 @@ class FSPluginClient extends ElectronBasePluginClient { ignorePermissionErrors: true, ignoreInitial: true, ignored: [ '**/node_modules/**', + '**/.git/index.lock', // this file is created and unlinked all the time when git is running on Windows ] }).on('all', async (eventName, path, stats) => { - let pathWithoutPrefix = path.replace(this.workingDir, '') pathWithoutPrefix = convertPathToPosix(pathWithoutPrefix) if (pathWithoutPrefix.startsWith('/')) pathWithoutPrefix = pathWithoutPrefix.slice(1) @@ -242,7 +246,6 @@ class FSPluginClient extends ElectronBasePluginClient { if (currentContent !== newContent) { try { - this.emit('change', eventName, pathWithoutPrefix) } catch (e) { console.log('error emitting change', e) diff --git a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx index 36ebb04a87..5a3bb9bc7a 100644 --- a/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx +++ b/libs/remix-ui/search/src/lib/components/results/ResultItem.tsx @@ -29,7 +29,6 @@ export const ResultItem = (props: ResultItemProps) => { useEffect(() => { if (props.file.forceReload) { - console.log('force reload') clearTimeout(reloadTimeOut.current) clearTimeout(loadTimeout.current) subscribed.current = true diff --git a/libs/remix-ui/search/src/lib/context/context.tsx b/libs/remix-ui/search/src/lib/context/context.tsx index 2df84fcdd3..7afb7355eb 100644 --- a/libs/remix-ui/search/src/lib/context/context.tsx +++ b/libs/remix-ui/search/src/lib/context/context.tsx @@ -203,7 +203,6 @@ export const SearchProvider = ({ text, createRegExFromFind() ) - console.log('RESULT', result) clearTimeout(clearSearchingTimeout.current) clearSearchingTimeout.current = setTimeout(() => value.setSearching(null), 500) return result @@ -423,7 +422,6 @@ export const SearchProvider = ({ }, [state.count]) useEffect(() => { - console.log('STATE CHANGED', files, state.find) if (state.find) { (async () => { try {