microsoft / microsoft/vscode-test-web

Using `vscode.RelativePattern` and `vscode.workspace.findFiles`

Open
#4 5 comments 6 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature-request
Dominant language
HTML
Stars
87
Forks
31
Avg merge
23h 49m
Merged PRs (30d)
5

Description

I've changed the helloworld-web-sample with this simple testing code below but it can't find files when running it with the vscode-test-web (files.length always 0). It works fine when I run it using the Run Web Extension in VS Code though (files.length > 0).

Is there a different way of using vscode.RelativePattern and vscode.workspace.findFiles for browser? Thanks!

diff --git a/helloworld-web-sample/src/web/extension.ts b/helloworld-web-sample/src/web/extension.ts
index 176a2dd..482892a 100644
--- a/helloworld-web-sample/src/web/extension.ts
+++ b/helloworld-web-sample/src/web/extension.ts
@@ -13,11 +13,13 @@ export function activate(context: vscode.ExtensionContext) {
 	// The command has been defined in the package.json file
 	// Now provide the implementation of the command with registerCommand
 	// The commandId parameter must match the command field in package.json
-	let disposable = vscode.commands.registerCommand('helloworld-web-sample.helloWorld', () => {
+	let disposable = vscode.commands.registerCommand('helloworld-web-sample.helloWorld', async () => {
 		// The code you place here will be executed every time your command is executed
 
 		// Display a message box to the user
-		vscode.window.showInformationMessage('Hello World from helloworld-web-sample in a web extension host!');
+		const relativePattern = new vscode.RelativePattern(vscode.workspace.workspaceFolders![0], "**/*");
+		const files = await vscode.workspace.findFiles(relativePattern);
+		await vscode.window.showInformationMessage(`Hello World from helloworld-web-sample in a web extension host! ${files.length}`);
 	});
 
 	context.subscriptions.push(disposable);

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with helloworld-web-sample/src/web/extension.ts and reproduce the issue through vscode-test-web using the shown RelativePattern and findFiles call. Compare the browser run with Run Web Extension in VS Code and determine the expected browser behavior; done means the sample's file lookup works as intended or the limitation and required usage are documented.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing, web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.