Skip to content

Commit

Permalink
Improved cancel state
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Mar 5, 2024
1 parent f5e48de commit 2309d48
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/views/jobManager/statusBar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getInstance } from "../../base";

const item = window.createStatusBarItem(`sqlJob`, StatusBarAlignment.Left);

export async function updateStatusBar(options: {newJob?: boolean, executing?: boolean} = {}) {
export async function updateStatusBar(options: {newJob?: boolean, cancelling?: boolean, jobIsBusy?: boolean, executing?: boolean} = {}) {
const instance = getInstance();
const connection = instance.getConnection();

Expand All @@ -19,6 +19,12 @@ export async function updateStatusBar(options: {newJob?: boolean, executing?: bo
if (options.executing) {
text = `$(sync~spin) Executing...`;
} else
if (options.cancelling) {
text = `$(sync~spin) Cancelling...`;
} else
if (options.jobIsBusy) {
text = `🙁 Job is busy`;
} else
if (options.newJob) {
text = `$(sync~spin) Spinning up job...`;
} else
Expand Down
7 changes: 6 additions & 1 deletion src/views/results/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import Document from "../../language/sql/document";
import { changedCache } from "../../language/providers/completionItemCache";
import { ParsedEmbeddedStatement, StatementGroup, StatementType } from "../../language/sql/types";
import Statement from "../../language/sql/statement";
import { ExplainTree, ContextType } from "./explain/nodes";
import { ExplainTree } from "./explain/nodes";
import { DoveResultsView, ExplainTreeItem } from "./explain/doveResultsView";
import { DoveNodeView, PropertyNode } from "./explain/doveNodeView";
import { DoveTreeDecorationProvider } from "./explain/doveTreeDecorationProvider";
Expand Down Expand Up @@ -60,10 +60,15 @@ export function initialise(context: vscode.ExtensionContext) {
vscode.commands.registerCommand(`vscode-db2i.statement.cancel`, async () => {
const selected = JobManager.getSelection();
if (selected) {
updateStatusBar({cancelling: true});
const cancelled = await selected.job.requestCancel();
if (cancelled) {
resultSetProvider.setError(`Statement canceled.`);
setCancelButtonVisibility(false);
updateStatusBar();
} else {
updateStatusBar({jobIsBusy: true});
setTimeout(() => updateStatusBar(), 2000);
}
}
}),
Expand Down

0 comments on commit 2309d48

Please sign in to comment.