@@ -32,7 +32,7 @@ var allowedGrepInputKeys = map[string]struct{}{
3232 "max_columns" : {}, "maxColumns" : {}, "max-columns" : {}, "--max-columns" : {},
3333 "context" : {}, "-C" : {}, "before_context" : {}, "beforeContext" : {}, "-B" : {}, "after_context" : {}, "afterContext" : {}, "-A" : {}, "line_numbers" : {}, "lineNumbers" : {}, "line-number" : {}, "--line-number" : {}, "-n" : {},
3434 "ignore_case" : {}, "case_insensitive" : {}, "caseInsensitive" : {}, "ignore-case" : {}, "--ignore-case" : {}, "-i" : {},
35- "fixed_strings" : {}, "fixedStrings" : {}, "fixed-strings" : {}, "--fixed-strings" : {}, "-F" : {}, "multiline" : {},
35+ "fixed_strings" : {}, "fixedStrings" : {}, "fixed-strings" : {}, "--fixed-strings" : {}, "-F" : {}, "multiline" : {}, "--multiline" : {}, "multiline-dotall" : {}, "--multiline-dotall" : {}, "-U" : {},
3636 "word_regexp" : {}, "wordRegexp" : {}, "word-regexp" : {}, "--word-regexp" : {}, "-w" : {},
3737 "invert_match" : {}, "invertMatch" : {}, "invert-match" : {}, "--invert-match" : {}, "-v" : {},
3838 "only_matching" : {}, "onlyMatching" : {}, "only-matching" : {}, "--only-matching" : {}, "-o" : {},
@@ -51,7 +51,7 @@ var grepSemanticNumberKeys = map[string]struct{}{
5151var grepSemanticBooleanKeys = map [string ]struct {}{
5252 "line_numbers" : {}, "lineNumbers" : {}, "line-number" : {}, "--line-number" : {}, "-n" : {},
5353 "ignore_case" : {}, "case_insensitive" : {}, "caseInsensitive" : {}, "ignore-case" : {}, "--ignore-case" : {}, "-i" : {},
54- "fixed_strings" : {}, "fixedStrings" : {}, "fixed-strings" : {}, "--fixed-strings" : {}, "-F" : {}, "multiline" : {},
54+ "fixed_strings" : {}, "fixedStrings" : {}, "fixed-strings" : {}, "--fixed-strings" : {}, "-F" : {}, "multiline" : {}, "--multiline" : {}, "multiline-dotall" : {}, "--multiline-dotall" : {}, "-U" : {},
5555 "word_regexp" : {}, "wordRegexp" : {}, "word-regexp" : {}, "--word-regexp" : {}, "-w" : {},
5656 "invert_match" : {}, "invertMatch" : {}, "invert-match" : {}, "--invert-match" : {}, "-v" : {},
5757 "only_matching" : {}, "onlyMatching" : {}, "only-matching" : {}, "--only-matching" : {}, "-o" : {},
@@ -154,6 +154,10 @@ type grepInput struct {
154154 NoIgnoreDash bool `json:"no-ignore,omitempty"`
155155 LongNoIgnore bool `json:"--no-ignore,omitempty"`
156156 Multiline bool `json:"multiline,omitempty"`
157+ LongMultiline bool `json:"--multiline,omitempty"`
158+ MultilineDotall bool `json:"multiline-dotall,omitempty"`
159+ LongMultilineDotall bool `json:"--multiline-dotall,omitempty"`
160+ ShortMultiline bool `json:"-U,omitempty"`
157161}
158162
159163type fileSearchMatch struct {
@@ -352,6 +356,14 @@ func NewGrepTool() tool.Tool {
352356 "no-ignore" : map [string ]any {"type" : "boolean" },
353357 "--no-ignore" : map [string ]any {"type" : "boolean" },
354358 "multiline" : map [string ]any {"type" : "boolean" },
359+ "--multiline" : map [string ]any {"type" : "boolean" },
360+ "multiline-dotall" : map [string ]any {
361+ "type" : "boolean" ,
362+ },
363+ "--multiline-dotall" : map [string ]any {
364+ "type" : "boolean" ,
365+ },
366+ "-U" : map [string ]any {"type" : "boolean" },
355367 },
356368 },
357369 },
@@ -520,7 +532,7 @@ func callGrep(ctx tool.Context, raw json.RawMessage, _ tool.ProgressSink) (contr
520532 BeforeContext : before ,
521533 AfterContext : after ,
522534 LineNumbers : grepLineNumbers (input , mode ),
523- Multiline : input . Multiline ,
535+ Multiline : grepMultiline ( input ) ,
524536 InvertMatch : grepInvertMatch (input ),
525537 OnlyMatching : onlyMatching ,
526538 CountMatches : countMatches ,
@@ -563,7 +575,7 @@ func callGrep(ctx tool.Context, raw json.RawMessage, _ tool.ProgressSink) (contr
563575 "files_without_match" : mode == "files_without_matches" ,
564576 "count_matches" : countMatches ,
565577 "no_ignore" : noIgnore ,
566- "multiline" : input . Multiline ,
578+ "multiline" : grepMultiline ( input ) ,
567579 "truncated" : truncated ,
568580 },
569581 }, nil
@@ -1204,11 +1216,11 @@ func compileGrepPattern(input grepInput) (*regexp.Regexp, error) {
12041216 pattern = `\b(?:` + pattern + `)\b`
12051217 }
12061218 switch {
1207- case grepCaseInsensitive (input ) && input . Multiline :
1219+ case grepCaseInsensitive (input ) && grepMultiline ( input ) :
12081220 pattern = "(?is:" + pattern + ")"
12091221 case grepCaseInsensitive (input ):
12101222 pattern = "(?i:" + pattern + ")"
1211- case input . Multiline :
1223+ case grepMultiline ( input ) :
12121224 pattern = "(?s:" + pattern + ")"
12131225 }
12141226 return regexp .Compile (pattern )
@@ -1275,6 +1287,14 @@ func grepOnlyMatching(input grepInput) bool {
12751287 input .ShortOnlyMatching
12761288}
12771289
1290+ func grepMultiline (input grepInput ) bool {
1291+ return input .Multiline ||
1292+ input .LongMultiline ||
1293+ input .MultilineDotall ||
1294+ input .LongMultilineDotall ||
1295+ input .ShortMultiline
1296+ }
1297+
12781298func grepFilesWithMatches (input grepInput ) bool {
12791299 return input .FilesWithMatch ||
12801300 input .FilesWithMatchAlt ||
0 commit comments