Escape markdown in tools' ui_text (#27502)

Escape markdown in tools' `ui_text`

<img width="628" alt="Screenshot 2025-03-26 at 10 43 23 AM"
src="https://github.com/user-attachments/assets/bb694821-aae7-4ccf-a35a-a3317b0222d5"
/>


Release Notes:

- N/A
This commit is contained in:
Richard Feldman 2025-03-26 11:27:02 -04:00 committed by GitHub
parent 82b0881dcb
commit 9eacac62a9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 108 additions and 86 deletions

View file

@ -12,6 +12,7 @@ use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use std::{cmp, fmt::Write, sync::Arc};
use ui::IconName;
use util::markdown::MarkdownString;
use util::paths::PathMatcher;
#[derive(Debug, Serialize, Deserialize, JsonSchema)]
@ -63,14 +64,12 @@ impl Tool for RegexSearchTool {
match serde_json::from_value::<RegexSearchToolInput>(input.clone()) {
Ok(input) => {
let page = input.page();
let regex = MarkdownString::escape(&input.regex);
if page > 1 {
format!(
"Get page {page} of search results for regex “`{}`”",
input.regex
)
format!("Get page {page} of search results for regex “`{regex}`”")
} else {
format!("Search files for regex “`{}`”", input.regex)
format!("Search files for regex “`{regex}`”")
}
}
Err(_) => "Search with regex".to_string(),