Commit f9ab09d
authored
Fix race condition in handleRemoveHistoryItem causing wrong current item on Windows
The `handleRemoveHistoryItem` method called `getCurrent()` after several async
operations. On Windows, VS Code fires `onDidChangeSelection` asynchronously
during awaits (after `refresh()` from `remove()`), which could change the
current item to an unexpected value before `getCurrent()` was called.
Fix by:
1. Capturing the current item *before* any async operations in
`handleRemoveHistoryItem`, and restoring it afterwards if the item is still
in history (i.e. it was not one of the removed items). Also add an explicit
`setCurrentItem(current)` call before `reveal` to sync the internal state in
case a deferred `onDidChangeSelection` changed it during the awaits.
2. Mocking `showInformationMessageWithAction` in the test to return immediately
instead of calling the real VS Code API, which could trigger additional async
event processing.
Fixes the failing "Test (windows-latest)" CI job:
QueryHistoryManager › handleRemoveHistoryItem › when the item is a variant
analysis › when in progress › when the item being removed is not selected
› should not change the selection1 parent 1c0f453 commit f9ab09d
2 files changed
Lines changed: 25 additions & 5 deletions
File tree
- extensions/ql-vscode
- src/query-history
- test/vscode-tests/no-workspace/query-history
Lines changed: 22 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
565 | 565 | | |
566 | 566 | | |
567 | 567 | | |
| 568 | + | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
568 | 575 | | |
569 | 576 | | |
570 | 577 | | |
| |||
602 | 609 | | |
603 | 610 | | |
604 | 611 | | |
605 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
606 | 623 | | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
607 | 628 | | |
608 | 629 | | |
609 | 630 | | |
| |||
Lines changed: 3 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
331 | 331 | | |
332 | 332 | | |
333 | 333 | | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
338 | 337 | | |
339 | 338 | | |
340 | 339 | | |
| |||
0 commit comments