Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions extensions/ql-vscode/src/query-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -492,8 +492,9 @@ export class QueryHistoryManager extends DisposableObject {
singleItem: QueryHistoryInfo,
multiSelect: QueryHistoryInfo[]
): Promise<void> {
// TODO will support remote queries
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local') {
if (!this.assertSingleQuery(finalMultiSelect) || (finalSingleItem && finalSingleItem.t !== 'local')) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you're not doing finalSingleItem?.t !== 'local' like in other places?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. In this case, if the selected query is remote, then we want this command to do nothing. If there is no selection, then we want to throw an error. It is trying to preserve previous behaviour.

However, in a future PR, I got rid of the throw clause. It's actually really difficult for a user to get into a situation where this command is invoked, but no query is selected. Also, if it does happen, then popping up an error message is a bit annoying.

So, for this PR, I was just planning on maintaining previous behaviour.

return;
}

Expand Down Expand Up @@ -581,7 +582,8 @@ export class QueryHistoryManager extends DisposableObject {
): Promise<void> {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local') {
// TODO will support remote queries
if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem?.t !== 'local') {
return;
}

Expand All @@ -605,7 +607,8 @@ export class QueryHistoryManager extends DisposableObject {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

try {
if (finalSingleItem.t !== 'local') {
// local queries only
if (finalSingleItem?.t !== 'local') {
throw new Error('Please select a local query.');
}

Expand All @@ -628,8 +631,9 @@ export class QueryHistoryManager extends DisposableObject {
singleItem: QueryHistoryInfo,
multiSelect: QueryHistoryInfo[]
) {
// TODO will support remote queries
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);
if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local') {
if (!this.assertSingleQuery(finalMultiSelect) || (finalSingleItem && finalSingleItem?.t !== 'local')) {
return;
}

Expand Down Expand Up @@ -660,6 +664,7 @@ export class QueryHistoryManager extends DisposableObject {
singleItem: LocalQueryInfo,
multiSelect: LocalQueryInfo[]
) {
// Local queries only
if (!this.assertSingleQuery(multiSelect)) {
return;
}
Expand All @@ -679,6 +684,8 @@ export class QueryHistoryManager extends DisposableObject {
singleItem: QueryHistoryInfo,
multiSelect: QueryHistoryInfo[]
) {
// Local queries only
// In the future, we may support cancelling remote queries, but this is not a short term plan.
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

(finalMultiSelect || [finalSingleItem]).forEach((item) => {
Expand All @@ -694,7 +701,8 @@ export class QueryHistoryManager extends DisposableObject {
) {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local') {
// TODO will support remote queries
if (!this.assertSingleQuery(finalMultiSelect) || (finalSingleItem && finalSingleItem?.t !== 'local')) {
return;
}

Expand All @@ -719,7 +727,8 @@ export class QueryHistoryManager extends DisposableObject {
) {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
// Local queries only
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
return;
}

Expand All @@ -743,7 +752,8 @@ export class QueryHistoryManager extends DisposableObject {
) {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
// Local queries only
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
return;
}
const query = finalSingleItem.completedQuery.query;
Expand All @@ -764,7 +774,8 @@ export class QueryHistoryManager extends DisposableObject {
) {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
// Local queries only
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
return;
}

Expand All @@ -779,7 +790,8 @@ export class QueryHistoryManager extends DisposableObject {
) {
const { finalSingleItem, finalMultiSelect } = this.determineSelection(singleItem, multiSelect);

if (!this.assertSingleQuery(finalMultiSelect) || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
// Local queries only
if (!this.assertSingleQuery(finalMultiSelect) || !finalSingleItem || finalSingleItem.t !== 'local' || !finalSingleItem.completedQuery) {
return;
}

Expand Down