Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workspace.findFiles don't works #6460

Open
frank-dspeed opened this issue Oct 29, 2019 · 8 comments · May be fixed by #14365
Open

Workspace.findFiles don't works #6460

frank-dspeed opened this issue Oct 29, 2019 · 8 comments · May be fixed by #14365
Labels
bug bugs found in the application help wanted issues meant to be picked up, require help performance issues related to performance search in workspace issues related to the search-in-workspace

Comments

@frank-dspeed
Copy link

Description

when opening a large project lets say a linuxRootFs search in folders or any other search returns no results on any pattern

Reproduction Steps

OS and Theia version:
theia next docker
Diagnostics:

@vince-fugnitto vince-fugnitto added the search in workspace issues related to the search-in-workspace label Oct 29, 2019
@akosyakov akosyakov added bug bugs found in the application help wanted issues meant to be picked up, require help performance issues related to performance labels Oct 30, 2019
@vnfedotov
Copy link
Contributor

Is there any chance of getting this fixed? It seems to affect workspaceContains activation event for plugins -- it doesn't fire in theia, while working fine in vscode. I've narrowed it down to workspace.findFiles that returns different results in theia, compared to vscode. It's a fairly basic C project with some build artifacts, file count is 361, so it's not even that big.

@vince-fugnitto
Copy link
Member

Is there any chance of getting this fixed?

@vnfedotov if you're interested, please feel free to provide a pull-request to address the issue.

@vnfedotov
Copy link
Contributor

@vince-fugnitto I'll look into it. Its FileSearchServiceImpl, is it?

@vnfedotov
Copy link
Contributor

@vince-fugnitto I think i've figured it out, but in my case it's a different issue related to ripgrep options, I've opened a new issue: #8669

@chroberino
Copy link

I am also having troubles with findFiles using Theia 1.53.2.

It looks like the vscode.workspace.findFiles() function in Theia respects .gitignore entries, which prevents files ignored by Git from being found by the function. This differs from VS Code, where findFiles() does not exclude files in .gitignore by default, leading to inconsistencies between the two environments.

@msujew msujew linked a pull request Oct 28, 2024 that will close this issue
1 task
@msujew
Copy link
Member

msujew commented Oct 28, 2024

I've submitted a PR to fix this. See #14365.

@msujew
Copy link
Member

msujew commented Oct 30, 2024

@chroberino Thanks for looking into it. Can you supply us with a git repo or something that reproduces this issue (and ideally the respective arguments for the findFiles call)? I cannot reproduce this, see discussion over in #14365.

@chroberino
Copy link

@msujew, sorry I totally missed your reply/question.

At the moment I don't have a public repo to share. But I can share the method where findFiles was failing.

Let me explain what I tried to do:
I am working on a VS Code extension to support remote debugging with GDB. For this extension I have implemented the following method:

private async generateInitGdb(): Promise<void> {
	const workspaceFolder = vscode.workspace.workspaceFolders?.[0].uri.fsPath;
	if (!workspaceFolder) {
		vscode.window.showErrorMessage("Workspace folder not found.");
		return;
	}

	const directories = new Set<string>();

	const searchFiles = async (extension: string) => {
		const files = await vscode.workspace.findFiles(`Temp/**/*.${extension}`);
		files.forEach(file => {
			const dir = path.dirname(file.fsPath);
			directories.add(dir);
		});
	};

	await searchFiles('out');
	//await searchFiles() for further file extensions of interest 

	// Check if there are directories to add to solib-search-path
	if (directories.size === 0) {
		vscode.window.showInformationMessage("No relevant files found; .initgdb file not created.");
		return;
	}

	// Create semicolon-separated list of directories
	const solibSearchPath = Array.from(directories).join(';');
	const initGdbContent = `set solib-search-path ${solibSearchPath}`;

	// Write to .initgdb file
	const initGdbPath = path.join(workspaceFolder, '.initgdb');
	fs.writeFileSync(initGdbPath, initGdbContent);

	vscode.window.showInformationMessage(".initgdb file generated successfully.");
}

Just for the sake of completeness:

import * as vscode from 'vscode';
import * as fs from 'fs';
import * as path from 'path';

The generateInitGdb() method searches the workspace’s Temp folder for debugger-relavant files (e.g. files with .out extension), collects their unique directories, and creates an .initgdb file that sets GDB's solib-search-path to these directories, helping GDB locate necessary debugging symbols for the project. This method has the issues using vscode.workspace.findFiles() in Theia, as it respects .gitignore by default. My .gitignore file contains a line saying /Temp/ which excludes the whole Temp folder.

Running my extension in VS Code and triggering this method finds all relevant files in the Temp folder and properly creates the .initgdb file.

Removing the line /Temp/ from .gitignore also allows my extension running in Theia to find all relavant in the Temp folder and create the .initgdb file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs found in the application help wanted issues meant to be picked up, require help performance issues related to performance search in workspace issues related to the search-in-workspace
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants