You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fix histogram escape key handling in VS Code extension (#2468)
When users clicked "Histogram" in VS Code and were prompted for the
number of shots, pressing Escape did not cancel the operation as
expected. Instead, the histogram was still displayed with a default
value of 100 shots.
## Root Cause
The issue was in the `handleShowHistogram` function in
`webviewPanel.ts`. The code used a fallback pattern that prevented
proper escape key detection:
```typescript
const numberOfShots =
(await window.showInputBox({
value: "100",
prompt: "Number of shots",
validateInput: validateShotsInput,
})) || "100";
// This check never worked because of the fallback above
if (numberOfShots === undefined) {
return;
}
```
When a user pressed Escape, `showInputBox()` returned `undefined`, but
the `|| "100"` fallback immediately assigned "100" to `numberOfShots`,
making the subsequent `undefined` check never true.
## Solution
Removed the problematic fallback and properly checked for escape key
before using the input value:
```typescript
const numberOfShotsInput = await window.showInputBox({
value: "100",
prompt: "Number of shots",
validateInput: validateShotsInput,
});
// Now this properly detects when user presses Escape
if (numberOfShotsInput === undefined) {
return;
}
const numberOfShots = numberOfShotsInput;
```
This pattern matches how escape key handling is implemented correctly in
other parts of the codebase, such as the Azure workspace actions and the
resource estimation commands.
## Testing
- ✅ VS Code extension builds successfully
- ✅ TypeScript compilation passes
- ✅ Linting and formatting checks pass
- ✅ No unrelated files modified
Fixes#1872.
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `update.code.visualstudio.com`
> - Triggering command: `node ./test/runTests.mjs ` (dns block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to my [firewall allow
list](https://gh.io/copilot/firewall-config)
>
> </details>
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: minestarks <[email protected]>
0 commit comments