Skip to content

Simpler withProgress calls#2165

Merged
koesie10 merged 3 commits intomainfrom
koesie10/simpler-progress-task
Mar 14, 2023
Merged

Simpler withProgress calls#2165
koesie10 merged 3 commits intomainfrom
koesie10/simpler-progress-task

Conversation

@koesie10
Copy link
Copy Markdown
Member

See the two separate commits. This will make withProgress easier to use by removing the required options argument and making it optional instead. This brings it in line with how commandRunnerWithProgress calls this function.

Checklist

  • CHANGELOG.md has been updated to incorporate all user visible changes made by this pull request.
  • Issues have been created for any UI or other user-facing changes made by this pull request.
  • [Maintainers only] If this pull request makes user-facing changes that require documentation changes, open a corresponding docs pull request in the github/codeql repo and add the ready-for-doc-review label there.

This removes the `args` from the `ProgressTask` passed to
`withProgress`. The `args` is only used by the
`commandRunnerWithProgress` and can easily be replaced by an anonymous
function that passes the `args` instead. This will simplify the
`ProgressTask` interface and make it easier to use.
This will make the progress options passed to `withProgress` optional by
moving it to be the second argument and setting a default value for the
`location`. This will make it much easier to use from a variety of
commands.
@koesie10 koesie10 marked this pull request as ready for review March 13, 2023 14:31
@koesie10 koesie10 requested a review from a team as a code owner March 13, 2023 14:31
@koesie10 koesie10 requested a review from a team March 13, 2023 14:32
Base automatically changed from koesie10/unify-command-runners to main March 14, 2023 08:54
Copy link
Copy Markdown
Contributor

@starcke starcke left a comment

Choose a reason for hiding this comment

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

Looks ok to me (but probably good to get second eyes). I wasnt super sure on the defaults.

Comment thread extensions/ql-vscode/src/contextual/templateProvider.ts Outdated
Comment thread extensions/ql-vscode/src/contextual/templateProvider.ts Outdated
Comment thread extensions/ql-vscode/src/local-databases.ts Outdated
Comment thread extensions/ql-vscode/src/commandRunner.ts Outdated
// Make certain properties within a type optional
type Optional<T, K extends keyof T> = Pick<Partial<T>, K> & Omit<T, K>;

export type ProgressOptions = Optional<VSCodeProgressOptions, "location">;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is cool, but I'm wondering what the advantage is over having a union of two types: one with the location attribute and one without?

Copy link
Copy Markdown
Contributor

@elenatanasoiu elenatanasoiu Mar 14, 2023

Choose a reason for hiding this comment

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

I can see you want to use VSCodeProgressOptions, but it's harder to read than two types added together.

🤔 Just wondering how to make this easier to understand when you first look at it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I didn't want to copy over the types of VSCodeProgressOptions, but you're right that this makes it harder to read. We can copy over the types of that type, but that means potentially some additional work when we update the vscode types, which might not be too bad for this type. What do you think?

Copy link
Copy Markdown
Contributor

@elenatanasoiu elenatanasoiu Mar 14, 2023

Choose a reason for hiding this comment

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

Yeah, ProgressOptions and ProgressLocation don't look that elaborate so it wouldn't be that much work to change. But we would need to remember to do it, which we probably won't unless we have solid testing around what we expect the progress UI to look like.

Since I don't think we have testing at this level, I'm leaning towards just using the root types like you've already done.

@koesie10 koesie10 merged commit 64d97aa into main Mar 14, 2023
@koesie10 koesie10 deleted the koesie10/simpler-progress-task branch March 14, 2023 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants