@@ -27,19 +27,26 @@ export class queryHistory implements TreeDataProvider<any> {
27
27
commands . registerCommand ( `vscode-db2i.queryHistory.prepend` , async ( newQuery ?: string ) => {
28
28
if ( newQuery && Config . ready ) {
29
29
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
+ }
31
41
32
42
// If it exists, remove it
33
- if ( existingQuery > 0 ) {
34
- currentList . splice ( existingQuery , 1 ) ;
43
+ if ( existingQueryi > 0 ) {
44
+ currentList . splice ( existingQueryi , 1 ) ;
35
45
}
36
46
37
47
// 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 ) ;
43
50
}
44
51
45
52
await Config . setPastQueries ( currentList ) ;
0 commit comments