-
Notifications
You must be signed in to change notification settings - Fork 162
accept window/progress instead of beginBuild/diagnosticEnd #231
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,7 +129,7 @@ function makeRlsProcess(): Promise<child_process.ChildProcess> { | |
}); | ||
|
||
return childProcessPromise.catch(() => { | ||
window.setStatusBarMessage('RLS could not be started'); | ||
stopSpinner('RLS could not be started'); | ||
return Promise.reject(undefined); | ||
}); | ||
} | ||
|
@@ -151,7 +151,7 @@ function startLanguageClient(context: ExtensionContext) | |
} | ||
warnOnMissingCargoToml(); | ||
|
||
window.setStatusBarMessage('RLS: starting up'); | ||
startSpinner('RLS', 'Starting'); | ||
|
||
warnOnRlsToml(); | ||
// Check for deprecated env vars. | ||
|
@@ -172,7 +172,7 @@ function startLanguageClient(context: ExtensionContext) | |
// Create the language client and start the client. | ||
lc = new LanguageClient('Rust Language Server', serverOptions, clientOptions); | ||
|
||
diagnosticCounter(); | ||
progressCounter(); | ||
|
||
const disposable = lc.start(); | ||
context.subscriptions.push(disposable); | ||
|
@@ -207,17 +207,41 @@ async function autoUpdate() { | |
} | ||
} | ||
|
||
function diagnosticCounter() { | ||
function progressCounter() { | ||
const runningProgress: { [index: string]: boolean } = {}; | ||
const asPercent = (fraction: number): string => `${Math.round(fraction * 100)}%`; | ||
let runningDiagnostics = 0; | ||
lc.onReady().then(() => { | ||
lc.onNotification(new NotificationType('rustDocument/beginBuild'), function(_f: any) { | ||
|
||
stopSpinner('RLS'); | ||
|
||
lc.onNotification(new NotificationType('window/progress'), function (progress: any) { | ||
if (progress.done) { | ||
delete runningProgress[progress.id]; | ||
} else { | ||
runningProgress[progress.id] = true; | ||
} | ||
if (Object.keys(runningProgress).length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
const status = | ||
typeof progress.percentage === 'number' ? asPercent(progress.percentage) : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you use an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok. |
||
progress.message ? progress.message : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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? There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 It's kinda interesting to see how long it spends doing |
||
progress.title ? `[${progress.title.toLowerCase()}]` : ''; | ||
startSpinner('RLS', status); | ||
} else { | ||
stopSpinner('RLS'); | ||
} | ||
}); | ||
|
||
// FIXME these are legacy notifications used by RLS ca jan 2018. | ||
// remove once we're certain we've progress on. | ||
lc.onNotification(new NotificationType('rustDocument/beginBuild'), function (_f: any) { | ||
runningDiagnostics++; | ||
startSpinner('RLS: working'); | ||
startSpinner('RLS', 'working'); | ||
}); | ||
lc.onNotification(new NotificationType('rustDocument/diagnosticsEnd'), function(_f: any) { | ||
lc.onNotification(new NotificationType('rustDocument/diagnosticsEnd'), function (_f: any) { | ||
runningDiagnostics--; | ||
if (runningDiagnostics <= 0) { | ||
stopSpinner('RLS: done'); | ||
stopSpinner('RLS'); | ||
} | ||
}); | ||
}); | ||
|
There was a problem hiding this comment.
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.There was a problem hiding this comment.
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.There was a problem hiding this comment.
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!