Skip to content

Commit 56b6e0b

Browse files
h9jianggopherbot
authored andcommitted
extension/src: change sub test input parameter from slice type to type
The vscode.executeCommand api accepts a slice of any as input parameters. But vscode will expand the slice into individual arguments before actually calling the receiver. E.g. a command with arg ["foo", 0, true] of type []any should have a corresponding command signature of func(string, number, boolean). a command with arg ["foo"] of type []any should have a corresponding command signature of func(string). Fix #3908 Change-Id: I0320cb52652e96bb7804ccfac66ddecc09593e3f Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/718200 Auto-Submit: Hongxiang Jiang <[email protected]> Reviewed-by: Madeline Kalil <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
1 parent 6b7a2b6 commit 56b6e0b

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
1515
minimum Go version remains Go 1.23. A new notification will now be sent to help
1616
users running older versions upgrade to Go 1.23+.
1717

18-
### Changse
18+
### Changes
1919

2020
* **Tool Management Refactoring**: The extension now correctly uses the tools
2121
specified in the `"go.lintTool"` and `"go.formatTool"` settings.
@@ -75,6 +75,9 @@ golang/vscode-go#3862).
7575
* Resolved a problem where `staticcheck` was being installed automatically even
7676
when it was not in use (golang/vscode-go#3898).
7777

78+
* Fix issue where sub test codelens runs sub test based on the cursor instead of
79+
the codelens' position (golang/vscode-go#3908).
80+
7881
## v0.51.1 (prerelease)
7982

8083
Date: 2025-10-27

extension/src/goTest.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ async function _subTestAtCursor(
181181
* @param args
182182
*/
183183
export function testAtCursor(cmd: TestAtCursorCmd): CommandFactory {
184-
return (ctx, goCtx) => (args: any) => {
184+
return (_, goCtx) => (args: any) => {
185185
const goConfig = getGoConfig();
186186
return _testAtCursor(goCtx, goConfig, cmd, args).catch((err) => {
187187
if (err instanceof NotFoundError) {
@@ -261,7 +261,10 @@ async function runTestAtCursor(
261261
}
262262

263263
/**
264-
* Executes the sub unit test at the primary cursor.
264+
* Executes the sub unit test.
265+
*
266+
* If the `args` is provided, run the subtest based on the test info provided in
267+
* the args. Otherwise, infer the test info from the cursor.
265268
*
266269
* @param cmd Whether the command is test or debug.
267270
*/
@@ -273,10 +276,10 @@ export function subTestAtCursor(cmd: SubTestAtCursorCmd): CommandFactory {
273276
* codelens provided by {@link GoRunTestCodeLensProvider}, args
274277
* specifies the function and subtest names.
275278
*/
276-
args?: [SubTestAtCursorArgs]
279+
args?: SubTestAtCursorArgs
277280
) => {
278281
try {
279-
return await _subTestAtCursor(goCtx, getGoConfig(), cmd, args?.[0]);
282+
return await _subTestAtCursor(goCtx, getGoConfig(), cmd, args);
280283
} catch (err) {
281284
if (err instanceof NotFoundError) {
282285
vscode.window.showInformationMessage(err.message);

0 commit comments

Comments
 (0)