Register Markdown language in some tests to silence error logs (#13066)
This PR registers the Markdown language in some of the tests in the `zed` crate to silence the error logs about the language not being found when the chat panel attempts to load it. Release Notes: - N/A
This commit is contained in:
parent
45ae0dcc2d
commit
9bc3c6810b
4 changed files with 50 additions and 6 deletions
1
Cargo.lock
generated
1
Cargo.lock
generated
|
@ -13336,6 +13336,7 @@ dependencies = [
|
||||||
"terminal_view",
|
"terminal_view",
|
||||||
"theme",
|
"theme",
|
||||||
"theme_selector",
|
"theme_selector",
|
||||||
|
"tree-sitter-markdown",
|
||||||
"tree-sitter-rust",
|
"tree-sitter-rust",
|
||||||
"urlencoding",
|
"urlencoding",
|
||||||
"util",
|
"util",
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use anyhow::Result;
|
use anyhow::{Context, Result};
|
||||||
use channel::{ChannelChat, ChannelStore, MessageParams};
|
use channel::{ChannelChat, ChannelStore, MessageParams};
|
||||||
use client::{UserId, UserStore};
|
use client::{UserId, UserStore};
|
||||||
use collections::HashSet;
|
use collections::HashSet;
|
||||||
|
@ -133,7 +133,7 @@ impl MessageEditor {
|
||||||
|
|
||||||
let markdown = language_registry.language_for_name("Markdown");
|
let markdown = language_registry.language_for_name("Markdown");
|
||||||
cx.spawn(|_, mut cx| async move {
|
cx.spawn(|_, mut cx| async move {
|
||||||
let markdown = markdown.await?;
|
let markdown = markdown.await.context("failed to load Markdown language")?;
|
||||||
buffer.update(&mut cx, |buffer, cx| {
|
buffer.update(&mut cx, |buffer, cx| {
|
||||||
buffer.set_language(Some(markdown), cx)
|
buffer.set_language(Some(markdown), cx)
|
||||||
})
|
})
|
||||||
|
|
|
@ -113,6 +113,7 @@ editor = { workspace = true, features = ["test-support"] }
|
||||||
gpui = { workspace = true, features = ["test-support"] }
|
gpui = { workspace = true, features = ["test-support"] }
|
||||||
language = { workspace = true, features = ["test-support"] }
|
language = { workspace = true, features = ["test-support"] }
|
||||||
project = { workspace = true, features = ["test-support"] }
|
project = { workspace = true, features = ["test-support"] }
|
||||||
|
tree-sitter-markdown.workspace = true
|
||||||
tree-sitter-rust.workspace = true
|
tree-sitter-rust.workspace = true
|
||||||
workspace = { workspace = true, features = ["test-support"] }
|
workspace = { workspace = true, features = ["test-support"] }
|
||||||
|
|
||||||
|
|
|
@ -1397,6 +1397,9 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
|
project.update(cx, |project, _cx| {
|
||||||
|
project.languages().add(markdown_language())
|
||||||
|
});
|
||||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
let workspace = window.root(cx).unwrap();
|
let workspace = window.root(cx).unwrap();
|
||||||
|
|
||||||
|
@ -1758,6 +1761,9 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
|
project.update(cx, |project, _cx| {
|
||||||
|
project.languages().add(markdown_language())
|
||||||
|
});
|
||||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
let workspace = window.root(cx).unwrap();
|
let workspace = window.root(cx).unwrap();
|
||||||
|
|
||||||
|
@ -1853,6 +1859,9 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
|
project.update(cx, |project, _cx| {
|
||||||
|
project.languages().add(markdown_language())
|
||||||
|
});
|
||||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
let workspace = window.root(cx).unwrap();
|
let workspace = window.root(cx).unwrap();
|
||||||
|
|
||||||
|
@ -1914,7 +1923,10 @@ mod tests {
|
||||||
app_state.fs.create_dir(Path::new("/root")).await.unwrap();
|
app_state.fs.create_dir(Path::new("/root")).await.unwrap();
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
project.update(cx, |project, _| project.languages().add(rust_lang()));
|
project.update(cx, |project, _| {
|
||||||
|
project.languages().add(markdown_language());
|
||||||
|
project.languages().add(rust_lang());
|
||||||
|
});
|
||||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
let worktree = cx.update(|cx| window.read(cx).unwrap().worktrees(cx).next().unwrap());
|
let worktree = cx.update(|cx| window.read(cx).unwrap().worktrees(cx).next().unwrap());
|
||||||
|
|
||||||
|
@ -2048,7 +2060,10 @@ mod tests {
|
||||||
app_state.fs.create_dir(Path::new("/root")).await.unwrap();
|
app_state.fs.create_dir(Path::new("/root")).await.unwrap();
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), [], cx).await;
|
let project = Project::test(app_state.fs.clone(), [], cx).await;
|
||||||
project.update(cx, |project, _| project.languages().add(rust_lang()));
|
project.update(cx, |project, _| {
|
||||||
|
project.languages().add(rust_lang());
|
||||||
|
project.languages().add(markdown_language());
|
||||||
|
});
|
||||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
|
|
||||||
// Create a new untitled buffer
|
// Create a new untitled buffer
|
||||||
|
@ -2123,6 +2138,9 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
|
project.update(cx, |project, _cx| {
|
||||||
|
project.languages().add(markdown_language())
|
||||||
|
});
|
||||||
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let window = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
let workspace = window.root(cx).unwrap();
|
let workspace = window.root(cx).unwrap();
|
||||||
|
|
||||||
|
@ -2212,6 +2230,9 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
|
project.update(cx, |project, _cx| {
|
||||||
|
project.languages().add(markdown_language())
|
||||||
|
});
|
||||||
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
|
let workspace = cx.add_window(|cx| Workspace::test_new(project.clone(), cx));
|
||||||
let pane = workspace
|
let pane = workspace
|
||||||
.read_with(cx, |workspace, _| workspace.active_pane().clone())
|
.read_with(cx, |workspace, _| workspace.active_pane().clone())
|
||||||
|
@ -2558,6 +2579,9 @@ mod tests {
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
let project = Project::test(app_state.fs.clone(), ["/root".as_ref()], cx).await;
|
||||||
|
project.update(cx, |project, _cx| {
|
||||||
|
project.languages().add(markdown_language())
|
||||||
|
});
|
||||||
let workspace = cx.add_window(|cx| Workspace::test_new(project, cx));
|
let workspace = cx.add_window(|cx| Workspace::test_new(project, cx));
|
||||||
let pane = workspace
|
let pane = workspace
|
||||||
.read_with(cx, |workspace, _| workspace.active_pane().clone())
|
.read_with(cx, |workspace, _| workspace.active_pane().clone())
|
||||||
|
@ -3097,12 +3121,15 @@ mod tests {
|
||||||
|
|
||||||
fn init_test(cx: &mut TestAppContext) -> Arc<AppState> {
|
fn init_test(cx: &mut TestAppContext) -> Arc<AppState> {
|
||||||
cx.update(|cx| {
|
cx.update(|cx| {
|
||||||
|
env_logger::try_init().ok();
|
||||||
|
|
||||||
let mut app_state = AppState::test(cx);
|
let mut app_state = AppState::test(cx);
|
||||||
|
|
||||||
let state = Arc::get_mut(&mut app_state).unwrap();
|
let state = Arc::get_mut(&mut app_state).unwrap();
|
||||||
env_logger::try_init().ok();
|
|
||||||
|
|
||||||
state.build_window_options = build_window_options;
|
state.build_window_options = build_window_options;
|
||||||
|
|
||||||
|
app_state.languages.add(markdown_language());
|
||||||
|
|
||||||
theme::init(theme::LoadThemes::JustBase, cx);
|
theme::init(theme::LoadThemes::JustBase, cx);
|
||||||
audio::init((), cx);
|
audio::init((), cx);
|
||||||
channel::init(&app_state.client, app_state.user_store.clone(), cx);
|
channel::init(&app_state.client, app_state.user_store.clone(), cx);
|
||||||
|
@ -3138,6 +3165,21 @@ mod tests {
|
||||||
Some(tree_sitter_rust::language()),
|
Some(tree_sitter_rust::language()),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn markdown_language() -> Arc<language::Language> {
|
||||||
|
Arc::new(language::Language::new(
|
||||||
|
language::LanguageConfig {
|
||||||
|
name: "Markdown".into(),
|
||||||
|
matcher: LanguageMatcher {
|
||||||
|
path_suffixes: vec!["md".to_string()],
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
..Default::default()
|
||||||
|
},
|
||||||
|
Some(tree_sitter_markdown::language()),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn assert_key_bindings_for(
|
fn assert_key_bindings_for(
|
||||||
window: AnyWindowHandle,
|
window: AnyWindowHandle,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue