@@ -3,7 +3,7 @@ import path from "path";
33
44import * as vscode from "vscode" ;
55
6- import { VersionManager , ActivationResult } from "./versionManager" ;
6+ import { VersionManager , ActivationResult , DetectionResult } from "./versionManager" ;
77import { WorkspaceChannel } from "../workspaceChannel" ;
88import { pathToUri } from "../common" ;
99
@@ -36,25 +36,37 @@ export class Asdf extends VersionManager {
3636 static async detect (
3737 _workspaceFolder : vscode . WorkspaceFolder ,
3838 _outputChannel : WorkspaceChannel ,
39- ) : Promise < vscode . Uri | undefined > {
39+ ) : Promise < DetectionResult > {
4040 // Check for v0.16+ executables first
4141 const executablePaths = Asdf . getPossibleExecutablePaths ( ) ;
4242 const asdfExecPaths = executablePaths . map ( ( dir ) => vscode . Uri . joinPath ( dir , "asdf" ) ) ;
4343 const execResult = await VersionManager . findFirst ( asdfExecPaths ) ;
4444 if ( execResult ) {
45- return execResult ;
45+ return { type : "path" , uri : execResult } ;
4646 }
4747
4848 // Check for < v0.16 scripts
49- return VersionManager . findFirst ( Asdf . getPossibleScriptPaths ( ) ) ;
49+ const scriptResult = await VersionManager . findFirst ( Asdf . getPossibleScriptPaths ( ) ) ;
50+ if ( scriptResult ) {
51+ return { type : "path" , uri : scriptResult } ;
52+ }
53+
54+ return { type : "none" } ;
5055 }
5156
5257 async activate ( ) : Promise < ActivationResult > {
5358 // Prefer the path configured by the user, then use detect() to find ASDF
5459 const configuredPath = await this . getConfiguredAsdfPath ( ) ;
55- const asdfUri = configuredPath
56- ? vscode . Uri . file ( configuredPath )
57- : await Asdf . detect ( this . workspaceFolder , this . outputChannel ) ;
60+ let asdfUri : vscode . Uri | undefined ;
61+
62+ if ( configuredPath ) {
63+ asdfUri = vscode . Uri . file ( configuredPath ) ;
64+ } else {
65+ const result = await Asdf . detect ( this . workspaceFolder , this . outputChannel ) ;
66+ if ( result . type === "path" ) {
67+ asdfUri = result . uri ;
68+ }
69+ }
5870
5971 if ( ! asdfUri ) {
6072 throw new Error (
0 commit comments