From 76c1160ffa626fc5f07b309420e6666eb79a3311 Mon Sep 17 00:00:00 2001 From: veetaha Date: Sun, 10 May 2020 18:35:33 +0300 Subject: Migrate flycheck to fully-lsp-compatible progress reports (introduce ra_progress crate) --- editors/code/src/main.ts | 3 -- editors/code/src/status_display.ts | 100 ------------------------------------- 2 files changed, 103 deletions(-) delete mode 100644 editors/code/src/status_display.ts (limited to 'editors') diff --git a/editors/code/src/main.ts b/editors/code/src/main.ts index a92c676fa..16a94fceb 100644 --- a/editors/code/src/main.ts +++ b/editors/code/src/main.ts @@ -5,7 +5,6 @@ import { promises as fs, PathLike } from "fs"; import * as commands from './commands'; import { activateInlayHints } from './inlay_hints'; -import { activateStatusDisplay } from './status_display'; import { Ctx } from './ctx'; import { Config, NIGHTLY_TAG } from './config'; import { log, assert, isValidExecutable } from './util'; @@ -103,8 +102,6 @@ export async function activate(context: vscode.ExtensionContext) { ctx.pushCleanup(activateTaskProvider(workspaceFolder)); - activateStatusDisplay(ctx); - activateInlayHints(ctx); vscode.workspace.onDidChangeConfiguration( diff --git a/editors/code/src/status_display.ts b/editors/code/src/status_display.ts deleted file mode 100644 index f9cadc8a2..000000000 --- a/editors/code/src/status_display.ts +++ /dev/null @@ -1,100 +0,0 @@ -import * as vscode from 'vscode'; - -import { WorkDoneProgress, WorkDoneProgressBegin, WorkDoneProgressReport, WorkDoneProgressEnd, Disposable } from 'vscode-languageclient'; - -import { Ctx } from './ctx'; - -const spinnerFrames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏']; - -export function activateStatusDisplay(ctx: Ctx) { - const statusDisplay = new StatusDisplay(ctx.config.checkOnSave.command); - ctx.pushCleanup(statusDisplay); - const client = ctx.client; - if (client != null) { - ctx.pushCleanup(client.onProgress( - WorkDoneProgress.type, - 'rustAnalyzer/cargoWatcher', - params => statusDisplay.handleProgressNotification(params) - )); - } -} - -class StatusDisplay implements Disposable { - packageName?: string; - - private i: number = 0; - private statusBarItem: vscode.StatusBarItem; - private command: string; - private timer?: NodeJS.Timeout; - - constructor(command: string) { - this.statusBarItem = vscode.window.createStatusBarItem( - vscode.StatusBarAlignment.Left, - 10, - ); - this.command = command; - this.statusBarItem.hide(); - } - - show() { - this.packageName = undefined; - - this.timer = - this.timer || - setInterval(() => { - this.tick(); - this.refreshLabel(); - }, 300); - - this.statusBarItem.show(); - } - - hide() { - if (this.timer) { - clearInterval(this.timer); - this.timer = undefined; - } - - this.statusBarItem.hide(); - } - - dispose() { - if (this.timer) { - clearInterval(this.timer); - this.timer = undefined; - } - - this.statusBarItem.dispose(); - } - - refreshLabel() { - if (this.packageName) { - this.statusBarItem.text = `${spinnerFrames[this.i]} cargo ${this.command} [${this.packageName}]`; - } else { - this.statusBarItem.text = `${spinnerFrames[this.i]} cargo ${this.command}`; - } - } - - handleProgressNotification(params: WorkDoneProgressBegin | WorkDoneProgressReport | WorkDoneProgressEnd) { - switch (params.kind) { - case 'begin': - this.show(); - break; - - case 'report': - if (params.message) { - this.packageName = params.message; - this.refreshLabel(); - } - break; - - case 'end': - this.hide(); - break; - } - } - - private tick() { - this.i = (this.i + 1) % spinnerFrames.length; - } -} -- cgit v1.2.3