mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-28 05:55:17 -07:00
feat: Multi-Directory Workspace Support (part1: add --include-directories option) (#4605)
Co-authored-by: Allen Hutchison <adh@google.com>
This commit is contained in:
@@ -22,6 +22,7 @@ describe('useCompletion', () => {
|
||||
|
||||
// A minimal mock is sufficient for these tests.
|
||||
const mockCommandContext = {} as CommandContext;
|
||||
let testDirs: string[];
|
||||
|
||||
async function createEmptyDir(...pathSegments: string[]) {
|
||||
const fullPath = path.join(testRootDir, ...pathSegments);
|
||||
@@ -51,8 +52,12 @@ describe('useCompletion', () => {
|
||||
testRootDir = await fs.mkdtemp(
|
||||
path.join(os.tmpdir(), 'completion-unit-test-'),
|
||||
);
|
||||
testDirs = [testRootDir];
|
||||
mockConfig = {
|
||||
getTargetDir: () => testRootDir,
|
||||
getWorkspaceContext: () => ({
|
||||
getDirectories: () => testDirs,
|
||||
}),
|
||||
getProjectRoot: () => testRootDir,
|
||||
getFileFilteringOptions: vi.fn(() => ({
|
||||
respectGitIgnore: true,
|
||||
@@ -79,6 +84,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest(''),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -108,6 +114,7 @@ describe('useCompletion', () => {
|
||||
const textBuffer = useTextBufferForTest(text);
|
||||
return useCompletion(
|
||||
textBuffer,
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -138,6 +145,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/help'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -170,6 +178,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest(''),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -191,6 +200,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest(''),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -215,6 +225,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/h'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -242,6 +253,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/h'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -270,6 +282,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -315,6 +328,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/command'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
largeMockCommands,
|
||||
mockCommandContext,
|
||||
@@ -372,6 +386,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -394,6 +409,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/mem'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -417,6 +433,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/usag'), // part of the word "usage"
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -443,6 +460,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/clear'), // No trailing space
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -474,6 +492,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest(query),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
mockSlashCommands,
|
||||
mockCommandContext,
|
||||
@@ -494,6 +513,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/clear '),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -514,6 +534,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/unknown-command'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -547,6 +568,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/memory'), // Note: no trailing space
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -584,6 +606,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/memory'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -619,6 +642,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/memory a'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -650,6 +674,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/memory dothisnow'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -692,6 +717,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/chat resume my-ch'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -735,6 +761,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/chat resume '),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -769,6 +796,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('/chat resume '),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -796,6 +824,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@s'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -829,6 +858,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@src/comp'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -854,6 +884,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@.'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -885,6 +916,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@d'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -910,6 +942,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -944,6 +977,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -974,6 +1008,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@d'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -1007,6 +1042,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -1039,6 +1075,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
useTextBufferForTest('@t'),
|
||||
testDirs,
|
||||
testRootDir,
|
||||
[],
|
||||
mockCommandContext,
|
||||
@@ -1085,6 +1122,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
mockBuffer,
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -1128,6 +1166,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
mockBuffer,
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -1173,6 +1212,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
mockBuffer,
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
@@ -1221,6 +1261,7 @@ describe('useCompletion', () => {
|
||||
const { result } = renderHook(() =>
|
||||
useCompletion(
|
||||
mockBuffer,
|
||||
testDirs,
|
||||
testRootDir,
|
||||
slashCommands,
|
||||
mockCommandContext,
|
||||
|
||||
Reference in New Issue
Block a user