Skip to content
This repository was archived by the owner on Nov 18, 2022. It is now read-only.

accept window/progress instead of beginBuild/diagnosticEnd #231

Merged
merged 4 commits into from
Mar 3, 2018

Conversation

algesten
Copy link
Contributor

This is the vscode side of rust-lang/rls#653

@algesten algesten force-pushed the progress-params branch 2 times, most recently from cf399c8 to 85d1c14 Compare January 14, 2018 16:30
@algesten
Copy link
Contributor Author

screen shot 2018-01-14 at 17 28 43

Moved spinner order that it reads RLS (spinner) <message> so when <message> part changes`, the whole row doesn't flicker around.

src/extension.ts Outdated
if (Object.keys(runningProgress).length) {
const status =
typeof progress.percentage === 'number' ? asPercent(progress.percentage) :
progress.message ? progress.message :
Copy link
Member

Choose a reason for hiding this comment

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

Title is ignored in favour of message, if it's specified - is that intended?
This leads to RLS * [build] followed by RLS * crate_name when building, where we lose information that we're building that crate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Xanewok This is indeed intended. I wanted to keep the information flow at the bottom terse, and it's mostly obviously what it's doing. The [<title>] is to get something rather than RLS *, but could maybe dropped.

It's kinda interesting to see how long it spends doing [diagnostics] though. Already now I can see we should look into performance here.

@algesten
Copy link
Contributor Author

One thing I wondered is whether we should make the plugin in an interim handle both beginBuild/diagnosticsEnd and the new progress so that we can handle both old and new RLS?

@Xanewok
Copy link
Member

Xanewok commented Jan 16, 2018

Since the user can specify the requested toolchain via the extension, I think there's no way around this other than just adding it in a backwards-compatibility fashion.
We could align releases with stable releases in general, but there's nothing stopping users from e.g. explicitly using stable Rust 1.23 and so it'd be best to keep the support for old messages.

@algesten
Copy link
Contributor Author

I fix

@algesten
Copy link
Contributor Author

@Xanewok @nrc I've rebased this off latest master.

This incarnation handles both the old beginBuild/diagnosticEnd as well as the new window/progress to not have to be synced with rust nightly release of rls-preview.

Copy link
Member

@nrc nrc left a comment

Choose a reason for hiding this comment

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

This looks good to me. r? @Xanewok

src/extension.ts Outdated
}
if (Object.keys(runningProgress).length) {
const status =
typeof progress.percentage === 'number' ? asPercent(progress.percentage) :
Copy link
Member

Choose a reason for hiding this comment

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

Can you use an if statment rather than these nested ternary operators, it's pretty hard to read as is.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok.

@algesten
Copy link
Contributor Author

@nrc done

Copy link
Member

@Xanewok Xanewok left a comment

Choose a reason for hiding this comment

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

I'd explore if it'd be feasible to use Set here to simplify changes made here a bit, but apart from that LGTM!

Sorry for making you wait so long! I knew I forgot about some r? review.

src/extension.ts Outdated
@@ -207,17 +207,45 @@ async function autoUpdate() {
}
}

function diagnosticCounter() {
function progressCounter() {
const runningProgress: { [index: string]: boolean } = {};
Copy link
Member

Choose a reason for hiding this comment

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

I'm really wonky with JS, but would it be possible to replace that with Set for clarity?

Also not really sure why/how it's allowed to be const, since it's clearly modified in the callbacks, but I guess that's TypeScript shenanigans that I'm missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Set is better.

const is not typescript shenanigans but javascript. It's not actually immutable (sadly), it's just the actual variable itself that is impossible to change. I.e.

const foo = 42;
foo = 43; // FAIL

Copy link
Member

Choose a reason for hiding this comment

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

Right, makes sense. Thanks for the changes!

src/extension.ts Outdated
} else {
runningProgress[progress.id] = true;
}
if (Object.keys(runningProgress).length) {
Copy link
Member

Choose a reason for hiding this comment

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

If Set is used, these can be simplified (as per above)

} else if (progress.message) {
status = progress.message;
} else if (progress.title) {
status = `[${progress.title.toLowerCase()}]`;
Copy link
Member

Choose a reason for hiding this comment

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

nit: I know it's up to clients to display this on the UI side, but shouldn't we just display it how servers send it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ultimately I don't really want to end up in this part of the logic. This is a last resort fallback. We should try to send percentages or messages instead. It looked really bad to me with the caps, but this just taste and style, so I'm only going to argue my case once :)

If you think it's an important point, I'll change it.

@algesten
Copy link
Contributor Author

algesten commented Mar 2, 2018

Let's land this :)

r? @Xanewok

@algesten
Copy link
Contributor Author

algesten commented Mar 3, 2018

I just double checked that latest rls master works with the changes here. All good.

@Xanewok Xanewok merged commit 77f3227 into rust-lang:master Mar 3, 2018
@Xanewok
Copy link
Member

Xanewok commented Mar 3, 2018

Merged, thanks for working on this!

@algesten algesten deleted the progress-params branch March 4, 2018 09:09
Xanewok added a commit to Xanewok/rls-vscode that referenced this pull request Mar 27, 2019
* stubbed out separate test projects for actual tests

* added Cargo.lock files
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants