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

No files found #3

Open
roadieroundup opened this issue Aug 25, 2024 · 20 comments
Open

No files found #3

roadieroundup opened this issue Aug 25, 2024 · 20 comments
Assignees

Comments

@roadieroundup
Copy link

Since a while ago I have been facing this problem when I try to create a barrel:

image

@ManuelGil ManuelGil self-assigned this Aug 25, 2024
@ManuelGil
Copy link
Owner

ManuelGil commented Aug 25, 2024

Hi @roadieroundup ,

The information you present is very minimal and may lead you to think that the extension is not working.

If I had to guess, you are using NextJS (or fork) and the issue only appears in folders that contain the characters '[' or ']' in their name.

This is a known bug that I have been fighting with for months but have not been able to come up with a solution and it is actually part of a function within the VSCode Core itself.

I am sorry for the issue and if it is the case I invite you to try to create the files manually in this type of folders or try with another extension since what you are looking for is the comfort as a development experience.

@roadieroundup
Copy link
Author

Hi @ManuelGil

Which additional information do you need?

I'm using vite with react and the error appears in any folder with .jsx files

@ManuelGil
Copy link
Owner

In order to recreate your issue, I would like to know first the configuration you have of the extension for this project. For example:

{
  "autoBarrel.language.defaultLanguage": "JavaScript",
  "autoBarrel.files.disableRecursiveBarrelling": false,
  "autoBarrel.files.includeExtensionOnExport": ["js", "jsx"],
  "autoBarrel.files.ignoreFilePathPatternOnExport": ["**/*.spec.*", "**/*.test.*"],
  "autoBarrel.files.keepExtensionOnExport": false,
  "autoBarrel.files.detectExportsInFiles": false,
  "autoBarrel.files.exportDefaultFilename": "filename",
  "autoBarrel.formatting.excludeSemiColonAtEndOfLine": true,
  "autoBarrel.formatting.useSingleQuotes": true,
  "autoBarrel.formatting.endOfLine": "crlf",
  "autoBarrel.formatting.insertFinalNewline": false,
}

@disarticulate
Copy link

I'm also getting this error. Is there a better way to get debug info.

The only additional information I have is this worked once, and then stopped. I've tried all the settings, and nothing works.
I set the following in settings.json

    "autoBarrel.language.defaultLanguage": "JavaScript",
    "autoBarrel.files.disableRecursiveBarrelling": false,
    "autoBarrel.files.includeExtensionOnExport": ["js", "vue"],
    "autoBarrel.files.ignoreFilePathPatternOnExport": ["**/*.spec.*", "**/*.test.*"],
    "autoBarrel.files.keepExtensionOnExport": false,
    "autoBarrel.files.detectExportsInFiles": false,
    "autoBarrel.files.exportDefaultFilename": "filename",
    "autoBarrel.formatting.excludeSemiColonAtEndOfLine": false,
    "autoBarrel.formatting.useSingleQuotes": true,
    "autoBarrel.formatting.endOfLine": "lf",
    "autoBarrel.formatting.insertFinalNewline": true,

I removed this line:

    "autoBarrel.files.ignoreFilePathPatternOnExport": ["**/*.spec.*", "**/*.test.*"],

It flashed a 'dont forget to update the file' message, but nothing happened.

vscode:

Version: 1.94.1 (user setup)
Commit: e10f2369d0d9614a452462f2e01cdc4aa9486296
Date: 2024-10-05T05:44:32.189Z
Electron: 30.5.1
ElectronBuildId: 10262041
Chromium: 124.0.6367.243
Node.js: 20.16.0
V8: 12.4.254.20-electron.0
OS: Windows_NT x64 10.0.22631

Is it possible you're not sanitizing folders on windows?

@disarticulate
Copy link

So it looks like you may want to update "findFiles" @ManuelGil/vscode-auto-barrel/blob/main/src/app/controllers/files.controller.ts
https://github.com/microsoft/vscode/blob/f287d2d847b29c4887f913f404c8ec4e84f4d61a/src/vs/workbench/api/common/extHost.api.impl.ts#L960

			findFiles: (include, exclude, maxResults?, token?) => {
				// Note, undefined/null have different meanings on "exclude"
				return extHostWorkspace.findFiles(include, exclude, maxResults, extension.identifier, token);
			},
			findFiles2: (filePattern: vscode.GlobPattern, options?: vscode.FindFiles2Options, token?: vscode.CancellationToken): Thenable<vscode.Uri[]> => {
				checkProposedApiEnabled(extension, 'findFiles2');
				return extHostWorkspace.findFiles2(filePattern, options, extension.identifier, token);
			},
			findFiles2New: (filePattern: vscode.GlobPattern[], options?: vscode.FindFiles2OptionsNew, token?: vscode.CancellationToken): Thenable<vscode.Uri[]> => {
				checkProposedApiEnabled(extension, 'findFiles2New');
				return extHostWorkspace.findFiles2New(filePattern, options, extension.identifier, token);
			},

This is probably more helpful:

https://github.com/microsoft/vscode/blob/f287d2d847b29c4887f913f404c8ec4e84f4d61a/src/vs/workbench/api/common/extHostWorkspace.ts#L455 for findFiles

Is it possible exclude or maxResults are truncating results? The error suggests maxResults 0 is being passed. Otherwise, i get a different seemingly correct report when exclude is removed, but it still doesn't act.

The first time it worked was perfect, so it's odd it stops working. That would suggest some kind of cache is being hit, but I've restarted multiple times; uninstalled, reinstaleld. testing other plugins, etc.

@disarticulate
Copy link

unrelated issue? You set the default in constants:

export const EXPORT_FILENAME: string = 'index';

then in config:

this.exportDefaultFilename =
      config.get<string>('files.exportDefaultFilename') ?? EXPORT_FILENAME;

When I try to change it to index, it's an error, listing:
image

looks like this is set under schema/config.schema.json

		"autoBarrel.files.exportDefaultFilename": {
			"type": "string",
			"default": "filename",
			"enum": [
				"filename",
				"camelCase",
				"pascalCase",
				"kebabCase",
				"snakeCase"
			],
			"enumDescriptions": [
				"Use the filename as the default export.",
				"Use camelCase as the default export.",
				"Use PascalCase as the default export.",
				"Use kebab-case as the default export.",
				"Use snake_case as the default export."
			],
			"scope": "resource",
			"description": "Filename to use when exporting the default export."
		},

Doesn't appear related or how it might be to this issue, but curious.

@disarticulate
Copy link

Just tried uninstalling almost everything, and no change with default install.

@ManuelGil
Copy link
Owner

Hi @disarticulate ,

Thank you so much for your comments. I made the changes you proposed and did some tests with a React project and a Vue project with the settings you suggested in the comments. In both cases the files were generated without problems.

2024-10-09 19_56_26-

This change is already published, please perform the relevant tests and share your results.

I look forward to hearing from you

@disarticulate
Copy link

bizarrely, the same error message after update:
image

The repo shows you're using the same findFiles, and I don't see how your code if it returns a list of promises is wrong.

As I noted above, there's two other findFiles functions on workspace that could be tried. It looks like they have a typed outputs and findFiles does not.

So, seems like it's an upstream issue. If you tried findFiles2 it'd look something like:

findFiles2(include,
        {
          exclude,
          options?.maxResults ?? Number.MAX_SAFE_INTEGER,
          followSymlinks: true,
          [...]
       }
)

Other than that, I dont see how it's failing to return files. they're all using _findFilesImpl method, so even the above still might return an empty array.

the private method is documented as:

	private async _findFilesImpl(
		// the old `findFiles` used `include` to query, but the new `findFiles2` uses `filePattern` to query.
		// `filePattern` is the proper way to handle this, since it takes less precedence than the ignore files.

So they suggest you move to the findFiles2 function, so I'd guess even if we reported this, they'd want you to try the findFiles2.

@ManuelGil
Copy link
Owner

Sorry, I didn't pay attention to the functions, it was my mistake.

Actually that is the internal API of VSCode. To develop the extensions you install the @types/vscode npm package. The only function available is findFiles as it is in the official VSCode extensions API documentation.

I have performed the test on several computers, I suggest you try it on a different computer and share your results with me.

You can also clone this repository and test on your own how the extension works.

@ManuelGil
Copy link
Owner

@roadieroundup @disarticulate

Recently created its own function for file tracking that would replace the use of VSCode's native findFiles function.

This update is now available.

I hope it will definitely fix this issue and help you.

@disarticulate
Copy link

this seems to work! Great! I had to restart when updating the settings, but otherwise it's fine.

To get it to work with vue:

  • detect the exports
  • Keep extension on export

Thanks again!

@disarticulate
Copy link

...unfortunately, this appears to be a heisenbug. It's reverted to not finding files. It's definitely an upstream issue with how ever vscode handles files. I'm using the ssh plugin.

@ManuelGil
Copy link
Owner

I'm going to have to spend a little more time checking what else might be affecting the performance of the extension.

I'll be reporting back if I find anything

@disarticulate
Copy link

So basically, I'm operating on 2-3 project workspaces. It works immediately upon installing. But after ignoring it for hours or whatever, and I need to create a new set of barrel files, it suddenly stops working.

It has become more reliable, but there must be some kind of cache inbetween invokes.

@ManuelGil
Copy link
Owner

I have uploaded a new update that may bring improvements to the way files are searched by removing the dependency on minimatch. In return, I have implemented the fast-glob library to search files efficiently with the use of patterns.

I have also added a workspace folder check and some additional error messages in order to have a better bug tracking.

Please test this update and confirm if it fixes the issue.

@oribenez
Copy link

oribenez commented Jan 2, 2025

I am using cursor which is a fork of vscode and I see the issue
image

@ManuelGil
Copy link
Owner

Hi @oribenez ,

I recently uploaded an update with a different text so that I could recognize the error.

Please download the new version and share the new error message.

@oribenez
Copy link

oribenez commented Jan 8, 2025

Hi @oribenez ,

I recently uploaded an update with a different text so that I could recognize the error.

Please download the new version and share the new error message.

Hi thank you for your help.
when I click on create barrel file:

image

I get this message
image

@ManuelGil
Copy link
Owner

Please share your settings for the extension

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants