@@ -6,6 +6,7 @@ import { Query, QueryState } from "../../connection/query";
6
6
import { updateStatusBar } from "../jobManager/statusBar" ;
7
7
import Configuration from "../../configuration" ;
8
8
import * as html from "./html" ;
9
+ import { JobStatus } from "../../connection/sqlJob" ;
9
10
10
11
export class ResultSetPanelProvider implements WebviewViewProvider {
11
12
_view : WebviewView | WebviewPanel ;
@@ -16,14 +17,25 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
16
17
this . loadingState = false ;
17
18
}
18
19
20
+ endQuery ( ) {
21
+ if ( this . currentQuery ) {
22
+ const hostJob = this . currentQuery . getHostJob ( ) ;
23
+ if ( hostJob && hostJob . getStatus ( ) === JobStatus . Busy ) {
24
+ // We are assuming the job is the same here.
25
+ commands . executeCommand ( `vscode-db2i.statement.cancel` , hostJob . id ) ;
26
+ }
27
+ this . currentQuery . close ( ) . then ( ( ) => {
28
+ this . currentQuery = undefined ;
29
+ } ) ;
30
+ }
31
+ }
32
+
19
33
resolveWebviewView ( webviewView : WebviewView | WebviewPanel , context ?: WebviewViewResolveContext , _token ?: CancellationToken ) {
20
34
this . _view = webviewView ;
21
35
22
36
this . _view . onDidDispose ( ( ) => {
23
37
this . _view = undefined ;
24
- this . currentQuery . close ( ) . then ( ( ) => {
25
- this . currentQuery = undefined ;
26
- } ) ;
38
+ this . endQuery ( ) ;
27
39
} ) ;
28
40
29
41
webviewView . webview . options = {
@@ -35,10 +47,7 @@ export class ResultSetPanelProvider implements WebviewViewProvider {
35
47
this . _view . webview . onDidReceiveMessage ( async ( message ) => {
36
48
switch ( message . command ) {
37
49
case `cancel` :
38
- commands . executeCommand ( `vscode-db2i.statement.cancel` ) ;
39
- if ( this . currentQuery ) {
40
- await this . currentQuery . close ( ) ;
41
- }
50
+ this . endQuery ( ) ;
42
51
break ;
43
52
44
53
default :
0 commit comments