windows: Fix inconsistent separators in buffer headers and breadcrumbs (#38898)
Make `resolve_full_path` use the appropriate separators, and return a `String`. As part of fixing the fallout from that type change, this also fixes a bunch of places in the agent code that were using `std::path::Path` operations on paths that could be non-local, by changing them to operate instead on strings and use the project's `PathStyle`. This clears the way a bit for making `full_path` also return a string instead of a `PathBuf`, but I've left that for a follow-up. Release Notes: - N/A
This commit is contained in:
@@ -26,13 +26,13 @@ use language_model::{
|
||||
use project::{AgentLocation, Project};
|
||||
use schemars::JsonSchema;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::{cmp, iter, mem, ops::Range, path::PathBuf, pin::Pin, sync::Arc, task::Poll};
|
||||
use std::{cmp, iter, mem, ops::Range, pin::Pin, sync::Arc, task::Poll};
|
||||
use streaming_diff::{CharOperation, StreamingDiff};
|
||||
use streaming_fuzzy_matcher::StreamingFuzzyMatcher;
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct CreateFilePromptTemplate {
|
||||
path: Option<PathBuf>,
|
||||
path: Option<String>,
|
||||
edit_description: String,
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ impl Template for CreateFilePromptTemplate {
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct EditFileXmlPromptTemplate {
|
||||
path: Option<PathBuf>,
|
||||
path: Option<String>,
|
||||
edit_description: String,
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ impl Template for EditFileXmlPromptTemplate {
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct EditFileDiffFencedPromptTemplate {
|
||||
path: Option<PathBuf>,
|
||||
path: Option<String>,
|
||||
edit_description: String,
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ impl EditAgent {
|
||||
let conversation = conversation.clone();
|
||||
let output = cx.spawn(async move |cx| {
|
||||
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||
let path = cx.update(|cx| snapshot.resolve_file_path(cx, true))?;
|
||||
let path = cx.update(|cx| snapshot.resolve_file_path(true, cx))?;
|
||||
let prompt = CreateFilePromptTemplate {
|
||||
path,
|
||||
edit_description,
|
||||
@@ -229,7 +229,7 @@ impl EditAgent {
|
||||
let edit_format = self.edit_format;
|
||||
let output = cx.spawn(async move |cx| {
|
||||
let snapshot = buffer.read_with(cx, |buffer, _| buffer.snapshot())?;
|
||||
let path = cx.update(|cx| snapshot.resolve_file_path(cx, true))?;
|
||||
let path = cx.update(|cx| snapshot.resolve_file_path(true, cx))?;
|
||||
let prompt = match edit_format {
|
||||
EditFormat::XmlTags => EditFileXmlPromptTemplate {
|
||||
path,
|
||||
|
||||
@@ -261,9 +261,8 @@ impl Tool for ReadFileTool {
|
||||
Ok(result)
|
||||
} else {
|
||||
// No line ranges specified, so check file size to see if it's too big.
|
||||
let path_buf = std::path::PathBuf::from(&file_path);
|
||||
let buffer_content =
|
||||
outline::get_buffer_content_or_outline(buffer.clone(), Some(&path_buf), cx)
|
||||
outline::get_buffer_content_or_outline(buffer.clone(), Some(&file_path), cx)
|
||||
.await?;
|
||||
|
||||
action_log.update(cx, |log, cx| {
|
||||
|
||||
Reference in New Issue
Block a user