0

I have a NextJS project that I'd like to disable searching for text in the .next folder.

Following this answer, I've added this to my preferences:

enter image description here

But still, I'm getting search results for that folder:

enter image description here

What could be the reason for this?

cbdeveloper
  • 27,898
  • 37
  • 155
  • 336
  • Does it work as you expect if there are no files from the `.next` folder open? There is an issue with vscode searching in open files even if they would otherwise be excluded by the `searc.exclude` setting. – Mark Dec 25 '22 at 23:49

1 Answers1

0

Have you tried excluding it just for the current search?

That works for me very easily. Here, I am searching for a div tag in a web project that has hundreds of them. If I exclude the "src" folder, none are found.

enter image description here

The approach you are taking is a persistent exclusion, which is more tricky

It is more tricky because there are ways of accidentally disabling your global exclusions.

From the VS Code help:

VS Code excludes some folders by default to reduce the number of search results that you are not interested in (for example: node_modules). Open settings to change these rules under the files.exclude and search.exclude section.

Note that glob patterns in the search view work differently than in settings such as files.exclude and search.exclude. In the settings, you must use **/example to match a folder named example in subfolder folder1/example in your workspace. In the search view, the ** prefix is assumed. The glob patterns in these settings are always evaluated relative to the path of the workspace folder.

Also note the Use Exclude Settings and Ignore Files toggle button in the files to exclude box. The toggle determines whether to exclude files that are ignored by your .gitignore files and/or matched by your files.exclude and search.exclude settings.

That last paragraph is the potential trap. I think it says, if you de-toggle it, then even though you have told VS Code in the settings to exclude ".next", it will nevertheless search everything including ".next".

Mark
  • 143,421
  • 24
  • 428
  • 436
ProfDFrancis
  • 8,816
  • 1
  • 17
  • 26