Skip to content

Commit

Permalink
fix: detect core src directory
Browse files Browse the repository at this point in the history
  • Loading branch information
mhuisi committed Nov 10, 2023
1 parent a5e1034 commit 6236a9e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 2 additions & 2 deletions vscode-lean4/src/utils/leanInstaller.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { window, TerminalOptions, OutputChannel, Disposable, EventEmitter, ProgressLocation, Uri } from 'vscode'
import { window, TerminalOptions, OutputChannel, EventEmitter, Uri } from 'vscode'
import { toolchainPath, addServerEnvPaths, getPowerShellPath, shouldAutofocusOutput, isRunningTest } from '../config'
import { ExecutionExitCode, ExecutionResult, batchExecute, batchExecuteWithProgress } from './batch'
import { ExecutionExitCode, ExecutionResult, batchExecute } from './batch'
import { readLeanVersion, isCoreLean4Directory } from './projectInfo';
import { join } from 'path';
import { logger } from './logger'
Expand Down
19 changes: 18 additions & 1 deletion vscode-lean4/src/utils/projectInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,26 @@ export async function isCoreLean4Directory(path: Uri): Promise<boolean> {
const licensePath = Uri.joinPath(path, 'LICENSE').fsPath
const licensesPath = Uri.joinPath(path, 'LICENSES').fsPath
const srcPath = Uri.joinPath(path, 'src').fsPath
return await fileExists(licensePath)

const isCoreLean4RootDirectory =
await fileExists(licensePath)
&& await fileExists(licensesPath)
&& await fileExists(srcPath)
if (isCoreLean4RootDirectory) {
return true
}

const initPath = Uri.joinPath(path, 'Init').fsPath
const leanPath = Uri.joinPath(path, 'Lean').fsPath
const kernelPath = Uri.joinPath(path, 'kernel').fsPath
const runtimePath = Uri.joinPath(path, 'runtime').fsPath

const isCoreLean4SrcDirectory =
await fileExists(initPath)
&& await fileExists(leanPath)
&& await fileExists(kernelPath)
&& await fileExists(runtimePath)
return isCoreLean4SrcDirectory
}

// Find the root of a Lean project and return an optional WorkspaceFolder for it,
Expand Down

0 comments on commit 6236a9e

Please sign in to comment.