Skip to content
This repository was archived by the owner on Mar 19, 2024. It is now read-only.

Commit 6118f11

Browse files
committed
Move periodic update check start logic to startServerProcess
1 parent bcf2551 commit 6118f11

File tree

1 file changed

+13
-15
lines changed

1 file changed

+13
-15
lines changed

lib/index.js

+13-15
Original file line numberDiff line numberDiff line change
@@ -479,17 +479,6 @@ class RustLanguageClient extends AutoLanguageClient {
479479
() => this._restartLanguageServers().catch(logErr)
480480
))
481481

482-
// check for updates (if enabled) every so often
483-
let periodicUpdateTimeoutId
484-
const periodicUpdate = async () => {
485-
await this._promptToUpdateToolchain().catch(logErr)
486-
periodicUpdateTimeoutId = setTimeout(periodicUpdate, PERIODIC_UPDATE_CHECK_MILLIS)
487-
}
488-
this.disposables.add(new Disposable(() => {
489-
clearTimeout(periodicUpdateTimeoutId)
490-
}))
491-
this._periodicUpdate = periodicUpdate
492-
493482
this.disposables.add(atom.commands.add(
494483
'atom-workspace',
495484
'ide-rust:restart-all-language-servers',
@@ -544,10 +533,19 @@ class RustLanguageClient extends AutoLanguageClient {
544533
}
545534

546535
async startServerProcess(projectPath) {
547-
if (this._periodicUpdate) {
548-
// if haven't started checking for updates yet start now
549-
this._periodicUpdate()
550-
delete this._periodicUpdate
536+
if (!this._periodicUpdateChecking) {
537+
// if haven't started periodic checks for updates yet start now
538+
let periodicUpdateTimeoutId
539+
const periodicUpdate = async () => {
540+
await this._promptToUpdateToolchain().catch(logErr)
541+
periodicUpdateTimeoutId = setTimeout(periodicUpdate, PERIODIC_UPDATE_CHECK_MILLIS)
542+
}
543+
this.disposables.add(new Disposable(() => {
544+
clearTimeout(periodicUpdateTimeoutId)
545+
delete this._periodicUpdateChecking
546+
}))
547+
this._periodicUpdateChecking = true
548+
periodicUpdate().catch(logErr)
551549
}
552550

553551
let cmdOverride = rlsCommandOverride()

0 commit comments

Comments
 (0)