From 6144ee1b5dcf793d90d05c0404e7cbf7f2e4aa78 Mon Sep 17 00:00:00 2001 From: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Date: Tue, 9 Jan 2024 20:50:34 +0100 Subject: [PATCH] Docs for indent_size_for_line and co --- crates/language/src/buffer.rs | 10 +++++++++- crates/language/src/highlight_map.rs | 4 ++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/language/src/buffer.rs b/crates/language/src/buffer.rs index b745ff6f43fbb88908989ca71dcdc11d9ed6657a..7863be8b9396c3da6a9a165365b68d17d7619ff7 100644 --- a/crates/language/src/buffer.rs +++ b/crates/language/src/buffer.rs @@ -1920,6 +1920,7 @@ impl Buffer { undone } + /// Manually redoes a specific transaction in the buffer's redo history. pub fn redo(&mut self, cx: &mut ModelContext) -> Option { let was_dirty = self.is_dirty(); let old_version = self.version.clone(); @@ -1933,6 +1934,7 @@ impl Buffer { } } + /// Manually undoes all changes until a given transaction in the buffer's redo history. pub fn redo_to_transaction( &mut self, transaction_id: TransactionId, @@ -1952,6 +1954,7 @@ impl Buffer { redone } + /// Override current completion triggers with the user-provided completion triggers. pub fn set_completion_triggers(&mut self, triggers: Vec, cx: &mut ModelContext) { self.completion_triggers = triggers.clone(); self.completion_triggers_timestamp = self.text.lamport_clock.tick(); @@ -1965,11 +1968,14 @@ impl Buffer { cx.notify(); } + /// Returns a list of strings which trigger a completion menu for this language. + /// Usually this is driven by LSP server which returns a list of trigger characters for completions. pub fn completion_triggers(&self) -> &[String] { &self.completion_triggers } } +#[doc(hidden)] #[cfg(any(test, feature = "test-support"))] impl Buffer { pub fn edit_via_marked_text( @@ -2042,10 +2048,12 @@ impl Deref for Buffer { } impl BufferSnapshot { + /// Returns [`IndentSize`] for a given line that respects user settings and /// language preferences. pub fn indent_size_for_line(&self, row: u32) -> IndentSize { indent_size_for_line(self, row) } - + /// Returns [`IndentSize`] for a given position that respects user settings + /// and language preferences. pub fn language_indent_size_at(&self, position: T, cx: &AppContext) -> IndentSize { let settings = language_settings(self.language_at(position), self.file(), cx); if settings.hard_tabs { diff --git a/crates/language/src/highlight_map.rs b/crates/language/src/highlight_map.rs index 270ac259c9d78eff8d36a2ee8c8038f117d33260..8829eb94ac576be4b1ad7bc6512fd4720cf81dcb 100644 --- a/crates/language/src/highlight_map.rs +++ b/crates/language/src/highlight_map.rs @@ -11,7 +11,7 @@ pub struct HighlightId(pub u32); const DEFAULT_SYNTAX_HIGHLIGHT_ID: HighlightId = HighlightId(u32::MAX); impl HighlightMap { - pub fn new(capture_names: &[&str], theme: &SyntaxTheme) -> Self { + pub(crate) fn new(capture_names: &[&str], theme: &SyntaxTheme) -> Self { // For each capture name in the highlight query, find the longest // key in the theme's syntax styles that matches all of the // dot-separated components of the capture name. @@ -51,7 +51,7 @@ impl HighlightMap { } impl HighlightId { - pub fn is_default(&self) -> bool { + pub(crate) fn is_default(&self) -> bool { *self == DEFAULT_SYNTAX_HIGHLIGHT_ID }