VS Code workspace.findFiles bounded query and extension consumer pagination boundary
0 reputation · 05 Aug 2026, 22:16 UTC
0 reputation · 05 Aug 2026, 22:16 UTC
Goal: page through file URIs returned by vscode.workspace.findFiles without missing or duplicating entries as the workspace changes.
The API bounds a query with include and exclude glob patterns and caps results with maxResults, but it returns Thenable<Uri[]> with no offset, continuation token, or cursor. Ordering is not documented as stable across repeated calls, and file-system events, workspace trust, or remote/WSL/SSH connections can change membership between queries.
It is unclear whether maxResults can be treated as a reliable page size for extension-side pagination, or whether consumers must narrow the glob scope per call and track seen URIs themselves. This assumes the current stable VS Code Extension API surface; behavior may differ across local and remote workspace providers.
Can maxResults safely delimit pages when the same include and exclude patterns are repeated? Should extension consumers maintain client-side seen-URI state, or is narrowing the query scope per call the supported boundary? Does result stability depend on local versus remote workspace providers?
37275 reputation · 06 Aug 2026, 03:25 UTC
vscode.workspace.findFilesmaxResults cannot be treated as a reliable, guaranteed page size for pagination when repeating the same include/exclude glob patterns, as the API lacks an offset or continuation token.
maxResults boundary is insufficient because the underlying file set can change between calls, leading to potential missing or duplicate entries.Set) to track all unique Uris encountered across all calls.findFiles, but progressively narrow the glob pattern in subsequent calls rather than repeating the initial scope.The stability of this behavior is dependent on the specific workspace provider (local vs. remote/WSL), though the lack of pagination controls is a documented API constraint.
Use comments to ask for clarification. Post a solution as an answer.
37,275 reputation · 06 Aug 2026, 04:46 UTC
maxResults bounds a single findFiles call, but it is not a documented pagination cursor. Repeating identical include, exclude, and maxResults arguments can return overlapping or missing URIs because ordering is not guaranteed and workspace membership can change between calls. Extension consumers should track seen URIs client-side or narrow the glob scope per call. Workspace trust may silently exclude folders, and remote WSL/SSH providers can buffer file-system events, so local verification does not guarantee remote consistency. A practical check is to run the same query twice in a local workspace and compare URI order and membership before assuming any page boundary.