@@ -27,19 +27,26 @@ export class queryHistory implements TreeDataProvider<any> {
2727 commands . registerCommand ( `vscode-db2i.queryHistory.prepend` , async ( newQuery ?: string ) => {
2828 if ( newQuery && Config . ready ) {
2929 let currentList = Config . getPastQueries ( ) ;
30- const existingQuery = currentList . findIndex ( queryItem => queryItem . query . trim ( ) === newQuery . trim ( ) ) ;
30+ const existingQueryi = currentList . findIndex ( queryItem => queryItem . query . trim ( ) === newQuery . trim ( ) ) ;
31+ const existingQuery = currentList [ existingQueryi ] ;
32+
33+ const newQueryItem : QueryHistoryItem = {
34+ query : newQuery ,
35+ unix : Math . floor ( Date . now ( ) / 1000 ) ,
36+ } ;
37+
38+ if ( existingQuery ) {
39+ newQueryItem . starred = existingQuery . starred ; // Preserve starred status
40+ }
3141
3242 // If it exists, remove it
33- if ( existingQuery > 0 ) {
34- currentList . splice ( existingQuery , 1 ) ;
43+ if ( existingQueryi > 0 ) {
44+ currentList . splice ( existingQueryi , 1 ) ;
3545 }
3646
3747 // If it's at the top, don't add it, it's already at the top
38- if ( existingQuery !== 0 ) {
39- currentList . splice ( 0 , 0 , {
40- query : newQuery ,
41- unix : Math . floor ( Date . now ( ) / 1000 )
42- } ) ;
48+ if ( existingQueryi !== 0 ) {
49+ currentList . splice ( 0 , 0 , newQueryItem ) ;
4350 }
4451
4552 await Config . setPastQueries ( currentList ) ;
0 commit comments