Merge branch 'main' into language-api-docs

This commit is contained in:
Max Brunsfeld 2024-01-18 15:04:54 -08:00
commit b65cf6d2d9
382 changed files with 12764 additions and 7823 deletions

View file

@ -60,7 +60,9 @@ pub use {tree_sitter_rust, tree_sitter_typescript};
pub use lsp::DiagnosticSeverity;
lazy_static! {
static ref BUFFER_DIFF_TASK: TaskLabel = TaskLabel::new();
/// A label for the background task spawned by the buffer to compute
/// a diff against the contents of its file.
pub static ref BUFFER_DIFF_TASK: TaskLabel = TaskLabel::new();
}
/// Indicate whether a [Buffer] has permissions to edit.
@ -337,6 +339,8 @@ pub enum Event {
Reparsed,
/// The buffer's diagnostics were updated.
DiagnosticsUpdated,
/// The buffer gained or lost editing capabilities.
CapabilityChanged,
/// The buffer was explicitly requested to close.
Closed,
}
@ -711,6 +715,7 @@ impl Buffer {
}
}
#[cfg(test)]
pub(crate) fn as_text_snapshot(&self) -> &text::BufferSnapshot {
&self.text
}
@ -731,6 +736,7 @@ impl Buffer {
&self.saved_version
}
/// The fingerprint of the buffer's text when the buffer was last saved or reloaded from disk.
pub fn saved_version_fingerprint(&self) -> RopeFingerprint {
self.file_fingerprint
}
@ -756,6 +762,12 @@ impl Buffer {
.set_language_registry(language_registry);
}
/// Assign the buffer a new [Capability].
pub fn set_capability(&mut self, capability: Capability, cx: &mut ModelContext<Self>) {
self.capability = capability;
cx.emit(Event::CapabilityChanged)
}
/// This method is called to signal that the buffer has been saved.
pub fn did_save(
&mut self,
@ -967,6 +979,8 @@ impl Buffer {
self.parsing_in_background
}
/// Indicates whether the buffer contains any regions that may be
/// written in a language that hasn't been loaded yet.
pub fn contains_unknown_injections(&self) -> bool {
self.syntax_map.lock().contains_unknown_injections()
}

View file

@ -275,7 +275,7 @@ async fn test_normalize_whitespace(cx: &mut gpui::TestAppContext) {
let version_before_format = format_diff.base_version.clone();
buffer.apply_diff(format_diff, cx);
// The outcome depends on the order of concurrent taks.
// The outcome depends on the order of concurrent tasks.
//
// If the edit occurred while searching for trailing whitespace ranges,
// then the trailing whitespace region touched by the edit is left intact.

View file

@ -1017,7 +1017,7 @@ impl LanguageRegistry {
if language.fake_adapter.is_some() {
let task = cx.spawn(|cx| async move {
let (servers_tx, fake_adapter) = language.fake_adapter.as_ref().unwrap();
let (server, mut fake_server) = lsp::LanguageServer::fake(
let (server, mut fake_server) = lsp::FakeLanguageServer::new(
fake_adapter.name.to_string(),
fake_adapter.capabilities.clone(),
cx.clone(),

View file

@ -14,7 +14,7 @@ use settings::Settings;
use std::{num::NonZeroU32, path::Path, sync::Arc};
/// Initializes the language settings.
pub(crate) fn init(cx: &mut AppContext) {
pub fn init(cx: &mut AppContext) {
AllLanguageSettings::register(cx);
}

View file

@ -258,19 +258,19 @@ fn test_typing_multiple_new_injections() {
let (buffer, syntax_map) = test_edit_sequence(
"Rust",
&[
"fn a() { dbg }",
"fn a() { dbg«!» }",
"fn a() { dbg!«()» }",
"fn a() { dbg!(«b») }",
"fn a() { dbg!(b«.») }",
"fn a() { dbg!(b.«c») }",
"fn a() { dbg!(b.c«()») }",
"fn a() { dbg!(b.c(«vec»)) }",
"fn a() { dbg!(b.c(vec«!»)) }",
"fn a() { dbg!(b.c(vec!«[]»)) }",
"fn a() { dbg!(b.c(vec![«d»])) }",
"fn a() { dbg!(b.c(vec![d«.»])) }",
"fn a() { dbg!(b.c(vec![d.«e»])) }",
"fn a() { test_macro }",
"fn a() { test_macro«!» }",
"fn a() { test_macro!«()» }",
"fn a() { test_macro!(«b») }",
"fn a() { test_macro!(b«.») }",
"fn a() { test_macro!(b.«c») }",
"fn a() { test_macro!(b.c«()») }",
"fn a() { test_macro!(b.c(«vec»)) }",
"fn a() { test_macro!(b.c(vec«!»)) }",
"fn a() { test_macro!(b.c(vec!«[]»)) }",
"fn a() { test_macro!(b.c(vec![«d»])) }",
"fn a() { test_macro!(b.c(vec![d«.»])) }",
"fn a() { test_macro!(b.c(vec![d.«e»])) }",
],
);
@ -278,7 +278,7 @@ fn test_typing_multiple_new_injections() {
&syntax_map,
&buffer,
&["field"],
"fn a() { dbg!(b.«c»(vec![d.«e»])) }",
"fn a() { test_macro!(b.«c»(vec![d.«e»])) }",
);
}