Merge branch 'main' into window_context_2

This commit is contained in:
Antonio Scandurra 2023-04-21 10:58:08 +02:00
commit c76b9794e4
45 changed files with 1760 additions and 882 deletions

View file

@ -58,7 +58,7 @@ postage = { workspace = true }
rand = { version = "0.8.3", optional = true }
serde = { workspace = true }
serde_derive = { workspace = true }
smallvec = { version = "1.6", features = ["union"] }
smallvec = { workspace = true }
smol = "1.2"
tree-sitter-rust = { version = "*", optional = true }
tree-sitter-html = { version = "*", optional = true }

View file

@ -4411,7 +4411,7 @@ async fn test_strip_whitespace_and_format_via_lsp(cx: &mut gpui::TestAppContext)
cx.set_state(
&[
"one ", //
"twoˇ", //
"twoˇ", //
"three ", //
"four", //
]
@ -4486,7 +4486,7 @@ async fn test_strip_whitespace_and_format_via_lsp(cx: &mut gpui::TestAppContext)
&[
"one", //
"", //
"twoˇ", //
"twoˇ", //
"", //
"three", //
"four", //
@ -4501,7 +4501,7 @@ async fn test_strip_whitespace_and_format_via_lsp(cx: &mut gpui::TestAppContext)
cx.assert_editor_state(
&[
"one ", //
"twoˇ", //
"twoˇ", //
"three ", //
"four", //
]

View file

@ -436,6 +436,7 @@ mod tests {
use indoc::indoc;
use language::{Diagnostic, DiagnosticSet};
use lsp::LanguageServerId;
use project::HoverBlock;
use smol::stream::StreamExt;
@ -620,7 +621,7 @@ mod tests {
}],
&snapshot,
);
buffer.update_diagnostics(set, cx);
buffer.update_diagnostics(LanguageServerId(0), set, cx);
});
// Hover pops diagnostic immediately

View file

@ -2764,6 +2764,15 @@ impl MultiBufferSnapshot {
.and_then(|(buffer, offset)| buffer.language_scope_at(offset))
}
pub fn language_indent_size_at<T: ToOffset>(
&self,
position: T,
cx: &AppContext,
) -> Option<IndentSize> {
let (buffer_snapshot, offset) = self.point_to_buffer_offset(position)?;
Some(buffer_snapshot.language_indent_size_at(offset, cx))
}
pub fn is_dirty(&self) -> bool {
self.is_dirty
}
@ -2791,7 +2800,7 @@ impl MultiBufferSnapshot {
) -> impl Iterator<Item = DiagnosticEntry<O>> + 'a
where
T: 'a + ToOffset,
O: 'a + text::FromAnchor,
O: 'a + text::FromAnchor + Ord,
{
self.as_singleton()
.into_iter()