windows: Fix tests on Windows (#22616)

Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla.c.maki@gmail.com>
This commit is contained in:
张小白 2025-02-05 22:30:09 +08:00 committed by GitHub
parent c252b5db16
commit 74c4dbd237
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
56 changed files with 1540 additions and 856 deletions

View file

@ -18,7 +18,7 @@ use task::{
ResolvedTask, TaskContext, TaskId, TaskTemplate, TaskTemplates, TaskVariables, VariableName,
};
use text::{Point, ToPoint};
use util::{post_inc, NumericPrefixWithSuffix, ResultExt as _};
use util::{paths::PathExt as _, post_inc, NumericPrefixWithSuffix, ResultExt as _};
use worktree::WorktreeId;
use crate::worktree_store::WorktreeStore;
@ -470,7 +470,7 @@ impl ContextProvider for BasicContextProvider {
let current_file = buffer
.file()
.and_then(|file| file.as_local())
.map(|file| file.abs_path(cx).to_string_lossy().to_string());
.map(|file| file.abs_path(cx).to_sanitized_string());
let Point { row, column } = location.range.start.to_point(&buffer_snapshot);
let row = row + 1;
let column = column + 1;
@ -502,14 +502,14 @@ impl ContextProvider for BasicContextProvider {
if let Some(Some(worktree_path)) = worktree_root_dir {
task_variables.insert(
VariableName::WorktreeRoot,
worktree_path.to_string_lossy().to_string(),
worktree_path.to_sanitized_string(),
);
if let Some(full_path) = current_file.as_ref() {
let relative_path = pathdiff::diff_paths(full_path, worktree_path);
if let Some(relative_path) = relative_path {
task_variables.insert(
VariableName::RelativeFile,
relative_path.to_string_lossy().into_owned(),
relative_path.to_sanitized_string(),
);
}
}