@@ -13,6 +13,11 @@ import { QueryHistoryConfig } from './config';
1313 * `TreeDataProvider` subclass below.
1414 */
1515
16+ export type QueryHistoryItemOptions = {
17+ label ?: string , // user-settable label
18+ queryText ?: string , // stored query for quick query
19+ }
20+
1621/**
1722 * One item in the user-displayed list of queries that have been run.
1823 */
@@ -25,7 +30,7 @@ export class QueryHistoryItem {
2530 constructor (
2631 info : EvaluationInfo ,
2732 public config : QueryHistoryConfig ,
28- public label ?: string , // user-settable label
33+ public options : QueryHistoryItemOptions = { } ,
2934 ) {
3035 this . queryName = helpers . getQueryName ( info ) ;
3136 this . databaseName = info . database . name ;
@@ -65,8 +70,8 @@ export class QueryHistoryItem {
6570 }
6671
6772 getLabel ( ) : string {
68- if ( this . label !== undefined )
69- return this . label ;
73+ if ( this . options . label !== undefined )
74+ return this . options . label ;
7075 return this . config . format ;
7176 }
7277
@@ -203,9 +208,9 @@ export class QueryHistoryManager {
203208 if ( response !== undefined ) {
204209 if ( response === '' )
205210 // Interpret empty string response as "go back to using default"
206- queryHistoryItem . label = undefined ;
211+ queryHistoryItem . options . label = undefined ;
207212 else
208- queryHistoryItem . label = response ;
213+ queryHistoryItem . options . label = response ;
209214 this . treeDataProvider . refresh ( ) ;
210215 }
211216 }
@@ -258,8 +263,8 @@ export class QueryHistoryManager {
258263 } ) ;
259264 }
260265
261- push ( evaluationInfo : EvaluationInfo ) {
262- const item = new QueryHistoryItem ( evaluationInfo , this . queryHistoryConfigListener ) ;
266+ push ( evaluationInfo : EvaluationInfo , options : QueryHistoryItemOptions = { } ) {
267+ const item = new QueryHistoryItem ( evaluationInfo , this . queryHistoryConfigListener , options ) ;
263268 this . treeDataProvider . push ( item ) ;
264269 this . updateTreeViewSelectionIfVisible ( ) ;
265270 }
@@ -277,7 +282,7 @@ export class QueryHistoryManager {
277282 const current = this . treeDataProvider . getCurrent ( ) ;
278283 if ( current != undefined ) {
279284 // We must fire the onDidChangeTreeData event to ensure the current element can be selected
280- // using `reveal` if the tree view was not visible when the current element was added.
285+ // using `reveal` if the tree view was not visible when the current element was added.
281286 this . treeDataProvider . refresh ( ) ;
282287 this . treeView . reveal ( current ) ;
283288 }
0 commit comments