This commit is contained in:
Elena Tanasoiu 2022-11-01 17:13:12 +00:00
Родитель 1e2e3b79d4
Коммит 334e93caf0
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 865B598BB92245B0
4 изменённых файлов: 30 добавлений и 3 удалений

Просмотреть файл

@ -1258,6 +1258,7 @@
"test:view": "jest",
"preintegration": "rm -rf ./out/vscode-tests && gulp",
"integration": "node ./out/vscode-tests/run-integration-tests.js no-workspace,minimal-workspace",
"no-workspace": "node ./out/vscode-tests/run-integration-tests.js no-workspace",
"cli-integration": "npm run preintegration && node ./out/vscode-tests/run-integration-tests.js cli-integration",
"update-vscode": "node ./node_modules/vscode/bin/install",
"format": "tsfmt -r && eslint . --ext .ts,.tsx --fix",

Просмотреть файл

@ -273,17 +273,23 @@ export class HistoryTreeDataProvider extends DisposableObject implements TreeDat
}
remove(item: QueryHistoryInfo) {
console.log('remove - this.current', this.current);
const isCurrent = this.current === item;
if (isCurrent) {
this.setCurrentItem();
}
const index = this.history.findIndex((i) => i === item);
console.log('remove - index', index);
if (index >= 0) {
this.history.splice(index, 1);
if (isCurrent && this.history.length > 0) {
const targetIndex = Math.min(index, this.history.length - 1);
console.log('remove - targetIndex', targetIndex);
console.log('Modified history:', this.history);
console.log('!!!!!!! fetch the thing', this.history[targetIndex]);
// Try to keep a current item, near the deleted item if there
// are any available.
this.setCurrentItem(this.history[Math.min(index, this.history.length - 1)]);
this.setCurrentItem(this.history[targetIndex]);
}
this.refresh();
}
@ -777,18 +783,27 @@ export class QueryHistoryManager extends DisposableObject {
case 'local':
// Removing in progress local queries is not supported. They must be cancelled first.
if (item.status !== QueryStatus.InProgress) {
console.log('Removing local query');
console.log('item', item);
this.treeDataProvider.remove(item);
item.completedQuery?.dispose();
// User has explicitly asked for this query to be removed.
// We need to delete it from disk as well.
await item.completedQuery?.query.deleteQuery();
} else {
console.log('Did not remove local query');
console.log('item', item);
}
break;
case 'remote':
console.log('Removing remote query');
console.log('item', item);
await this.removeRemoteQuery(item);
break;
case 'variant-analysis':
console.log('Removing variant analysis');
console.log('item', item);
await this.removeVariantAnalysis(item);
break;
default:
@ -798,6 +813,7 @@ export class QueryHistoryManager extends DisposableObject {
await this.writeQueryHistory();
const current = this.treeDataProvider.getCurrent();
if (current !== undefined) {
await this.treeView.reveal(current, { select: true });
await this.openQueryResults(current);
@ -1453,6 +1469,7 @@ the file in the file explorer and dragging it into the workspace.`
}
private async openQueryResults(item: QueryHistoryInfo) {
console.log('openQueryResults - item type', item.t);
if (item.t === 'local') {
await this.localQueriesResultsView.showResults(item as CompletedLocalQueryInfo, WebviewReveal.Forced, false);
} else if (item.t === 'remote') {

Просмотреть файл

@ -102,6 +102,7 @@ export async function splatQueryHistory(queries: QueryHistoryInfo[], fsPath: str
}
// remove incomplete local queries since they cannot be recreated on restart
const filteredQueries = queries.filter(q => q.t === 'local' ? q.completedQuery !== undefined : true);
const data = JSON.stringify({
// version 2:
// - adds the `variant-analysis` type

Просмотреть файл

@ -106,7 +106,6 @@ describe('query-history', () => {
createMockVariantAnalysisHistoryItem(QueryStatus.InProgress)
];
allHistory = shuffleHistoryItems([...localQueryHistory, ...remoteQueryHistory, ...variantAnalysisHistory]);
});
afterEach(async () => {
@ -262,6 +261,9 @@ describe('query-history', () => {
});
describe('handleRemoveHistoryItem', () => {
describe('if you remove the selected item', () => {
});
it('should remove an item and not select a new one', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
// initialize the selection
@ -291,16 +293,20 @@ describe('query-history', () => {
expect(queryHistoryManager.treeDataProvider.allHistory).not.to.contain(toDelete);
});
it('should remove an item and select a new one', async () => {
it.only('should remove an item and select a new one', async () => {
queryHistoryManager = await createMockQueryHistory(allHistory);
// deleting the selected item automatically selects next item
const toDelete = allHistory[1];
const newSelected = allHistory[2];
console.log('toDelete', toDelete);
console.log('newSelected', newSelected);
// avoid triggering the callback by setting the field directly
// select the item we want
await queryHistoryManager.treeView.reveal(toDelete, { select: true });
queryHistoryManager.treeDataProvider.setCurrentItem(toDelete);
await queryHistoryManager.handleRemoveHistoryItem(toDelete, [toDelete]);
expectToHaveBeenRemoved(toDelete, queryHistoryManager);
@ -315,6 +321,8 @@ describe('query-history', () => {
});
function expectToHaveBeenSelected(selected: QueryHistoryInfo) {
console.log('expectToHaveBeenSelected - selected', selected);
switch (selected.t) {
case 'local':
expect(localQueriesResultsViewStub.showResults).to.have.been.calledWith(selected);