Merge branch 'main' into gpui2

This commit is contained in:
Antonio Scandurra 2023-10-12 10:55:17 +02:00
commit 23f11fcd5e
71 changed files with 1588 additions and 783 deletions

View file

@ -41,4 +41,36 @@ impl ReleaseChannel {
ReleaseChannel::Stable => "stable",
}
}
pub fn url_scheme(&self) -> &'static str {
match self {
ReleaseChannel::Dev => "zed-dev://",
ReleaseChannel::Preview => "zed-preview://",
ReleaseChannel::Stable => "zed://",
}
}
pub fn link_prefix(&self) -> &'static str {
match self {
ReleaseChannel::Dev => "https://zed.dev/dev/",
ReleaseChannel::Preview => "https://zed.dev/preview/",
ReleaseChannel::Stable => "https://zed.dev/",
}
}
}
pub fn parse_zed_link(link: &str) -> Option<&str> {
for release in [
ReleaseChannel::Dev,
ReleaseChannel::Preview,
ReleaseChannel::Stable,
] {
if let Some(stripped) = link.strip_prefix(release.link_prefix()) {
return Some(stripped);
}
if let Some(stripped) = link.strip_prefix(release.url_scheme()) {
return Some(stripped);
}
}
None
}

View file

@ -139,6 +139,12 @@ impl<P> PathLikeWithPosition<P> {
column: None,
})
} else {
let maybe_col_str =
if maybe_col_str.ends_with(FILE_ROW_COLUMN_DELIMITER) {
&maybe_col_str[..maybe_col_str.len() - 1]
} else {
maybe_col_str
};
match maybe_col_str.parse::<u32>() {
Ok(col) => Ok(Self {
path_like: parse_path_like_str(path_like_str)?,
@ -241,7 +247,6 @@ mod tests {
"test_file.rs:1::",
"test_file.rs::1:2",
"test_file.rs:1::2",
"test_file.rs:1:2:",
"test_file.rs:1:2:3",
] {
let actual = parse_str(input);
@ -277,6 +282,14 @@ mod tests {
column: None,
},
),
(
"crates/file_finder/src/file_finder.rs:1902:13:",
PathLikeWithPosition {
path_like: "crates/file_finder/src/file_finder.rs".to_string(),
row: Some(1902),
column: Some(13),
},
),
];
for (input, expected) in input_and_expected {