microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
162.44k stars 28.62k forks source link

`vscode.ExcludeSettingOptions.None` does not seem to work #226861

Open connor4312 opened 2 weeks ago

connor4312 commented 2 weeks ago

Test extension:

``` import * as vscode from 'vscode'; import * as fs from 'fs/promises'; import * as path from 'path'; import * as assert from 'assert'; export function activate(context: vscode.ExtensionContext) { const disposable = vscode.commands.registerCommand('extension.helloWorld', async () => { const wf = vscode.workspace.workspaceFolders![0].uri; await vscode.workspace.getConfiguration('files').update('exclude', { '**/*.fileexclude.*': true, '**/fileexclude/**': true, }, vscode.ConfigurationTarget.Workspace); await vscode.workspace.getConfiguration('search').update('exclude', { '**/*.searchexclude.*': true, '**/searchexclude/**': true, }, vscode.ConfigurationTarget.Workspace); makeAllFiles([ { name: '.gitignore', content: '**/bar.txt' }, 'foo.txt', 'bar.txt', 'fileexclude/foo.txt', 'fileexclude/bar.txt', 'searchexclude/foo.txt', 'searchexclude/bar.txt', 'nested1/foo.txt', 'nested1/bar.txt', 'nested2/foo.txt', 'nested2/bar.txt', ]); let output = ''; output += assertUris( ['foo.txt', 'fileexclude/foo.txt', 'nested1/foo.txt', 'nested2/foo.txt', 'searchexclude/foo.txt'], await vscode.workspace.findFiles2New([new vscode.RelativePattern(wf, '**/*.txt')], { useExcludeSettings: vscode.ExcludeSettingOptions.None }) ); const doc = await vscode.workspace.openTextDocument({ content: output, language: 'plaintext', }); await vscode.window.showTextDocument(doc); }); function assertUris(expected: string[], uris: vscode.Uri[]) { try { const actual = uris.map(u => path.relative(vscode.workspace.workspaceFolders![0].uri.fsPath, u.fsPath)); assert.deepStrictEqual(actual.sort(), expected.sort()); } catch (e) { return String(e) + '\n\n'; } return `Case OK (${JSON.stringify(expected)})\n`; } async function makeAllFiles(files: (string | {name: string, content: string})[]) { const wf = vscode.workspace.workspaceFolders![0].uri.fsPath; for (const file of files) { const name = typeof file === 'string' ? file : file.name; const content = typeof file === 'string' ? '' : file.content; const target = path.join(wf, name); await fs.mkdir(path.dirname(target), { recursive: true }); await fs.writeFile(target, content); } } context.subscriptions.push(disposable); } ```

Fails with:

AssertionError [ERR_ASSERTION]: Expected values to be strictly deep-equal:
+ actual - expected

  [
+   'foo.txt',
+   'nested1/foo.txt',
+   'nested2/foo.txt'
-   'fileexclude/foo.txt',
-   'foo.txt',
-   'nested1/foo.txt',
-   'nested2/foo.txt',
-   'searchexclude/foo.txt'
  ]

I expected { useExcludeSettings: vscode.ExcludeSettingOptions.FilesExclude } would not use my search exclude setting (only SearchAndFilesExclude would.)

andreamah commented 2 weeks ago

I think I'll need to pair with you on this tomorrow. I'm trying to repro on linux rn and it seems like everything is correct? But I think I ran into behavior like this earlier today 🤔