Fix #597.
This commit is contained in:
committed by
Andrew Eisenberg
parent
7c48c5f887
commit
f4775954b6
@@ -43,7 +43,7 @@ import { spawnIdeServer } from './ide-server';
|
||||
import { InterfaceManager } from './interface';
|
||||
import { WebviewReveal } from './interface-utils';
|
||||
import { ideServerLogger, logger, queryServerLogger } from './logging';
|
||||
import { QueryHistoryManager } from './query-history';
|
||||
import { QueryHistoryManager, updateTreeItemContextValue } from './query-history';
|
||||
import { CompletedQuery } from './query-results';
|
||||
import * as qsClient from './queryserver-client';
|
||||
import { displayQuickQuery } from './quick-query';
|
||||
@@ -406,6 +406,10 @@ async function activateWithInstalledDistribution(
|
||||
);
|
||||
const item = qhm.addQuery(info);
|
||||
await showResultsForCompletedQuery(item, WebviewReveal.NotForced);
|
||||
// The call to showResults potentially creates SARIF file;
|
||||
// Update the tree item context value to allow viewing that
|
||||
// SARIF file from context menu.
|
||||
await updateTreeItemContextValue(item);
|
||||
} catch (e) {
|
||||
if (e instanceof UserCancellationException) {
|
||||
if (e.silent) {
|
||||
|
||||
@@ -50,6 +50,15 @@ const SHOW_QUERY_TEXT_QUICK_EVAL_MSG = `\
|
||||
*/
|
||||
const FAILED_QUERY_HISTORY_ITEM_ICON = 'media/red-x.svg';
|
||||
|
||||
export async function updateTreeItemContextValue(element: CompletedQuery): Promise<void> {
|
||||
// Mark this query history item according to whether it has a
|
||||
// SARIF file so that we can make context menu items conditionally
|
||||
// available.
|
||||
element.treeItem!.contextValue = (await element.query.hasInterpretedResults())
|
||||
? 'interpretedResultsItem'
|
||||
: 'rawResultsItem';
|
||||
}
|
||||
|
||||
/**
|
||||
* Tree data provider for the query history view.
|
||||
*/
|
||||
@@ -77,6 +86,9 @@ class HistoryTreeDataProvider
|
||||
constructor(private ctx: ExtensionContext) { }
|
||||
|
||||
async getTreeItem(element: CompletedQuery): Promise<vscode.TreeItem> {
|
||||
if (element.treeItem !== undefined)
|
||||
return element.treeItem;
|
||||
|
||||
const it = new vscode.TreeItem(element.toString());
|
||||
|
||||
it.command = {
|
||||
@@ -85,12 +97,8 @@ class HistoryTreeDataProvider
|
||||
arguments: [element],
|
||||
};
|
||||
|
||||
// Mark this query history item according to whether it has a
|
||||
// SARIF file so that we can make context menu items conditionally
|
||||
// available.
|
||||
it.contextValue = (await element.query.hasInterpretedResults())
|
||||
? 'interpretedResultsItem'
|
||||
: 'rawResultsItem';
|
||||
element.treeItem = it;
|
||||
updateTreeItemContextValue(element);
|
||||
|
||||
if (!element.didRunSuccessfully) {
|
||||
it.iconPath = path.join(
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { env } from 'vscode';
|
||||
import { env, TreeItem } from 'vscode';
|
||||
|
||||
import { QueryWithResults, tmpDir, QueryInfo } from './run-queries';
|
||||
import * as messages from './messages';
|
||||
@@ -17,6 +17,7 @@ export class CompletedQuery implements QueryWithResults {
|
||||
readonly database: DatabaseInfo;
|
||||
readonly logFileLocation?: string;
|
||||
options: QueryHistoryItemOptions;
|
||||
treeItem?: TreeItem;
|
||||
dispose: () => void;
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user