Links to channel notes (#7262)
Release Notes: - Added outline support for Markdown files - Added the ability to link to channel notes: https://zed.dev/channel/zed-283/notes#Roadmap
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
(atx_heading
|
||||
.
|
||||
(_) @context
|
||||
.
|
||||
(_) @name ) @item
|
||||
+18
-12
@@ -314,7 +314,10 @@ fn main() {
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
Ok(Some(OpenRequest::OpenChannelNotes { channel_id })) => {
|
||||
Ok(Some(OpenRequest::OpenChannelNotes {
|
||||
channel_id,
|
||||
heading,
|
||||
})) => {
|
||||
triggered_authentication = true;
|
||||
let app_state = app_state.clone();
|
||||
let client = client.clone();
|
||||
@@ -323,11 +326,11 @@ fn main() {
|
||||
let _ = authenticate(client, &cx).await;
|
||||
let workspace_window =
|
||||
workspace::get_any_active_workspace(app_state, cx.clone()).await?;
|
||||
let _ = workspace_window
|
||||
.update(&mut cx, |_, cx| {
|
||||
ChannelView::open(channel_id, cx.view().clone(), cx)
|
||||
})?
|
||||
.await?;
|
||||
let workspace = workspace_window.root_view(&cx)?;
|
||||
cx.update_window(workspace_window.into(), |_, cx| {
|
||||
ChannelView::open(channel_id, heading, workspace, cx)
|
||||
})?
|
||||
.await?;
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
@@ -369,16 +372,19 @@ fn main() {
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
OpenRequest::OpenChannelNotes { channel_id } => {
|
||||
OpenRequest::OpenChannelNotes {
|
||||
channel_id,
|
||||
heading,
|
||||
} => {
|
||||
let app_state = app_state.clone();
|
||||
let open_notes_task = cx.spawn(|mut cx| async move {
|
||||
let workspace_window =
|
||||
workspace::get_any_active_workspace(app_state, cx.clone()).await?;
|
||||
let _ = workspace_window
|
||||
.update(&mut cx, |_, cx| {
|
||||
ChannelView::open(channel_id, cx.view().clone(), cx)
|
||||
})?
|
||||
.await?;
|
||||
let workspace = workspace_window.root_view(&cx)?;
|
||||
cx.update_window(workspace_window.into(), |_, cx| {
|
||||
ChannelView::open(channel_id, heading, workspace, cx)
|
||||
})?
|
||||
.await?;
|
||||
anyhow::Ok(())
|
||||
});
|
||||
cx.update(|cx| open_notes_task.detach_and_log_err(cx))
|
||||
|
||||
@@ -7,6 +7,7 @@ use futures::channel::mpsc::{UnboundedReceiver, UnboundedSender};
|
||||
use futures::channel::{mpsc, oneshot};
|
||||
use futures::{FutureExt, SinkExt, StreamExt};
|
||||
use gpui::{AppContext, AsyncAppContext, Global};
|
||||
use itertools::Itertools;
|
||||
use language::{Bias, Point};
|
||||
use release_channel::parse_zed_link;
|
||||
use std::collections::HashMap;
|
||||
@@ -34,6 +35,7 @@ pub enum OpenRequest {
|
||||
},
|
||||
OpenChannelNotes {
|
||||
channel_id: u64,
|
||||
heading: Option<String>,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -100,10 +102,20 @@ impl OpenListener {
|
||||
if let Some(slug) = parts.next() {
|
||||
if let Some(id_str) = slug.split("-").last() {
|
||||
if let Ok(channel_id) = id_str.parse::<u64>() {
|
||||
if Some("notes") == parts.next() {
|
||||
return Some(OpenRequest::OpenChannelNotes { channel_id });
|
||||
} else {
|
||||
let Some(next) = parts.next() else {
|
||||
return Some(OpenRequest::JoinChannel { channel_id });
|
||||
};
|
||||
|
||||
if let Some(heading) = next.strip_prefix("notes#") {
|
||||
return Some(OpenRequest::OpenChannelNotes {
|
||||
channel_id,
|
||||
heading: Some([heading].into_iter().chain(parts).join("/")),
|
||||
});
|
||||
} else if next == "notes" {
|
||||
return Some(OpenRequest::OpenChannelNotes {
|
||||
channel_id,
|
||||
heading: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user