mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-13 05:12:55 -07:00
Iteration
This commit is contained in:
@@ -311,7 +311,7 @@ class GrepToolInvocation extends BaseToolInvocation<
|
|||||||
|
|
||||||
llmContent += `:\n---\n`;
|
llmContent += `:\n---\n`;
|
||||||
|
|
||||||
if (matchCount <= 3 && matchCount > 0 && !this.params.names_only) {
|
if (matchCount === 1 && matchCount > 0 && !this.params.names_only) {
|
||||||
for (const filePath in matchesByFile) {
|
for (const filePath in matchesByFile) {
|
||||||
const fileMatches = matchesByFile[filePath];
|
const fileMatches = matchesByFile[filePath];
|
||||||
let fileLines: string[] | null = null;
|
let fileLines: string[] | null = null;
|
||||||
@@ -332,10 +332,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
|||||||
|
|
||||||
for (const match of fileMatches) {
|
for (const match of fileMatches) {
|
||||||
if (fileLines) {
|
if (fileLines) {
|
||||||
const startLine = Math.max(0, match.lineNumber - 1 - 15);
|
const startLine = Math.max(0, match.lineNumber - 1 - 50);
|
||||||
const endLine = Math.min(
|
const endLine = Math.min(
|
||||||
fileLines.length,
|
fileLines.length,
|
||||||
match.lineNumber - 1 + 15 + 1,
|
match.lineNumber - 1 + 50 + 1,
|
||||||
);
|
);
|
||||||
const contextLines = fileLines.slice(startLine, endLine);
|
const contextLines = fileLines.slice(startLine, endLine);
|
||||||
|
|
||||||
|
|||||||
@@ -313,7 +313,7 @@ class GrepToolInvocation extends BaseToolInvocation<
|
|||||||
|
|
||||||
// Greedy Grep: If match count is low and no context was requested, automatically return context.
|
// Greedy Grep: If match count is low and no context was requested, automatically return context.
|
||||||
if (
|
if (
|
||||||
matchCount <= 3 &&
|
matchCount === 1 &&
|
||||||
matchCount > 0 &&
|
matchCount > 0 &&
|
||||||
!this.params.names_only &&
|
!this.params.names_only &&
|
||||||
!this.params.context &&
|
!this.params.context &&
|
||||||
@@ -340,10 +340,10 @@ class GrepToolInvocation extends BaseToolInvocation<
|
|||||||
const newFileMatches: GrepMatch[] = [];
|
const newFileMatches: GrepMatch[] = [];
|
||||||
const seenLines = new Set<number>();
|
const seenLines = new Set<number>();
|
||||||
for (const match of fileMatches) {
|
for (const match of fileMatches) {
|
||||||
const startLine = Math.max(0, match.lineNumber - 1 - 15);
|
const startLine = Math.max(0, match.lineNumber - 1 - 50);
|
||||||
const endLine = Math.min(
|
const endLine = Math.min(
|
||||||
fileLines.length,
|
fileLines.length,
|
||||||
match.lineNumber - 1 + 15 + 1,
|
match.lineNumber - 1 + 50 + 1,
|
||||||
);
|
);
|
||||||
for (let i = startLine; i < endLine; i++) {
|
for (let i = startLine; i < endLine; i++) {
|
||||||
if (!seenLines.has(i + 1)) {
|
if (!seenLines.has(i + 1)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user