Change PathLikeWithPosition<P> into a non-generic type and replace ad-hoc Windows path parsing (#15373)
This simplifies `PathWithPosition` by making the common use case concrete and removing the manual, incomplete Windows path parsing. Windows paths also don't get '/'s replaced by '\\'s anymore to limit the responsibility of the code to just parsing out the suffix and creating `PathBuf` from the rest. `Path::file_name()` is now used to extract the filename and potential suffix instead of manual parsing from the full input. This way e.g. Windows paths that begin with a drive letter are handled correctly without platform-specific hacks. Release Notes: - N/A
This commit is contained in:
parent
41c550cbe1
commit
13dcb42c1c
8 changed files with 184 additions and 270 deletions
|
@ -39,7 +39,7 @@ use ui::{
|
|||
RadioWithLabel, Tooltip,
|
||||
};
|
||||
use ui_input::{FieldLabelLayout, TextField};
|
||||
use util::paths::PathLikeWithPosition;
|
||||
use util::paths::PathWithPosition;
|
||||
use util::ResultExt;
|
||||
use workspace::notifications::NotifyResultExt;
|
||||
use workspace::OpenOptions;
|
||||
|
@ -991,7 +991,7 @@ impl DevServerProjects {
|
|||
project
|
||||
.paths
|
||||
.into_iter()
|
||||
.map(|path| PathLikeWithPosition::from_path(PathBuf::from(path)))
|
||||
.map(|path| PathWithPosition::from_path(PathBuf::from(path)))
|
||||
.collect(),
|
||||
app_state,
|
||||
OpenOptions::default(),
|
||||
|
|
|
@ -19,7 +19,7 @@ use ui::{
|
|||
h_flex, v_flex, FluentBuilder as _, Icon, IconName, IconSize, InteractiveElement, IntoElement,
|
||||
Label, LabelCommon, Styled, StyledExt as _, ViewContext, VisualContext, WindowContext,
|
||||
};
|
||||
use util::paths::PathLikeWithPosition;
|
||||
use util::paths::PathWithPosition;
|
||||
use workspace::{AppState, ModalView, Workspace};
|
||||
|
||||
#[derive(Deserialize)]
|
||||
|
@ -345,7 +345,7 @@ pub fn connect_over_ssh(
|
|||
|
||||
pub async fn open_ssh_project(
|
||||
connection_options: SshConnectionOptions,
|
||||
paths: Vec<PathLikeWithPosition<PathBuf>>,
|
||||
paths: Vec<PathWithPosition>,
|
||||
app_state: Arc<AppState>,
|
||||
_open_options: workspace::OpenOptions,
|
||||
cx: &mut AsyncAppContext,
|
||||
|
@ -398,7 +398,7 @@ pub async fn open_ssh_project(
|
|||
for path in paths {
|
||||
project
|
||||
.update(cx, |project, cx| {
|
||||
project.find_or_create_worktree(&path.path_like, true, cx)
|
||||
project.find_or_create_worktree(&path.path, true, cx)
|
||||
})?
|
||||
.await?;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue