Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix confusing download dialog popup #599

Merged
merged 1 commit into from
Apr 29, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/hlsBinaries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,9 @@ export async function findHaskellLanguageServer(
: new InstalledTool('stack');
const ghcInstalled = (await executableExists('ghc'))
? new InstalledTool('ghc')
: await toolInstalled(context, logger, 'ghc', recGHC!);
// if recGHC is null, that means user disabled automatic handling,
// so we pretend it's installed in order to ignore it
: (recGHC !== null ? await toolInstalled(context, logger, 'ghc', recGHC) : new InstalledTool('ghc'));
const toInstall = [hlsInstalled, cabalInstalled, stackInstalled, ghcInstalled]
.filter((tool) => !tool.installed)
.map((tool) => tool.nameWithVersion);
Expand Down Expand Up @@ -903,7 +905,7 @@ class InstalledTool {
* @param version Version of the tool, expected to be either SemVer or PVP versioned.
* @param installed Is this tool currently installed?
*/
public constructor(readonly name: string, readonly version: string = '', readonly installed: boolean = true) {
public constructor(readonly name: string, readonly version?: string, readonly installed: boolean = true) {
this.nameWithVersion = `${name}-${version}`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will render now as "*-undefined" if it is ever shown which isn't much better, imo.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't like this class, because we create an instance even if there is no such version. It obscures control flow. I'll have more time this evening.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will render now as "*-undefined" if it is ever shown which isn't much better, imo.

Well, if there's undefined falling through in this codepath, then that's a bug. Because undefined in this context means "default" and should have been resolved before.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But I also suck hard at OOP, so.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this class

Yeah, it is basically a record, not really a class.
Anyway, I prefer it over the unnamed tuple it was before :)

Because undefined in this context means "default" and should have been resolved before.

True

}
}