From 2544db3025ec79eb331b35d22de65e6b1a5155a0 Mon Sep 17 00:00:00 2001 From: LU XIANGRUI <1078666705@qq.com> Date: Wed, 25 Nov 2026 14:59:24 +0900 Subject: [PATCH] feat(dart): show closing labels at the end of the line (#5766) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Dart files show closing labels after a widget's or call's closing bracket at the end of the line (`), // Column`), from the Dart server's dart/textDocument/publishClosingLabels, now requested at initialization. They are inlay hints of a new closingLabel kind, kept per document and server instance, dropped on the next edit until the server publishes again; several labels closing on one line share one hint. Editor › Inlay Hints › Closing labels (on by default) turns them off. Right-click Disable now writes the kind's own setting (it wrote inlay.type instead of inlay.types for type hints). Part of #4096 Co-authored-by: wildcatDownstairs <26499420+wildcatDownstairs@users.noreply.github.com> --- crates/ide-core/src/editor_settings.rs | 3 + crates/ide-lsp/src/closing_labels.rs | 105 ++++++++++++++++++ crates/ide-lsp/src/handler.rs | 18 +++ crates/ide-lsp/src/lib.rs | 43 +++++++ crates/ide-lsp/src/notebook.rs | 1 + crates/ide-lsp/src/types.rs | 2 + crates/ide-lsp/tests/mock_server.rs | 34 ++++++ languages/dart.toml | 2 +- src/bindings.ts | 6 +- src/editor/lsp/inlay.test.ts | 31 ++++++ src/editor/lsp/inlay.ts | 21 +++- .../settings/pages/editor/InlayHintsPanel.tsx | 11 ++ src/platform/editorSettings.ts | 1 + src/platform/locales/text/en.json | 1 + src/platform/locales/text/zh.json | 1 + 15 files changed, 272 insertions(+), 8 deletions(-) create mode 100644 crates/ide-lsp/src/closing_labels.rs diff --git a/crates/ide-core/src/editor_settings.rs b/crates/ide-core/src/editor_settings.rs index c7addabb8..62e156dcb 100644 --- a/crates/ide-core/src/editor_settings.rs +++ b/crates/ide-core/src/editor_settings.rs @@ -362,6 +362,8 @@ pub struct InlayHintsSettings { pub parameters: bool, /// Hints of other kinds (chaining, closing labels…). pub other: bool, + /// The Dart server's closing labels (`// Column` after a widget's closing bracket). + pub closing_labels: bool, pub disabled_languages: Vec, /// Code vision as a whole (usages, author and language-server lenses); the switches below apply while it is on. pub code_vision: bool, @@ -394,6 +396,7 @@ impl Default for InlayHintsSettings { types: true, parameters: true, other: true, + closing_labels: true, disabled_languages: Vec::new(), code_vision: true, code_vision_usages: true, diff --git a/crates/ide-lsp/src/closing_labels.rs b/crates/ide-lsp/src/closing_labels.rs new file mode 100644 index 000000000..b9005af4b --- /dev/null +++ b/crates/ide-lsp/src/closing_labels.rs @@ -0,0 +1,105 @@ +//! The Dart analysis server's closing labels (`dart/textDocument/publishClosingLabels`): the +//! widget or call a closing `)` / `]` ends, shown after it at the end of the line (`// Column`). + +use crate::convert::Conv; +use crate::text::{DocText, Encoding, col_to_byte, units}; +use crate::types::{InlayHint, InlayKind}; +use ide_core::Pos; +use lsp_types as lsp; +use serde::Deserialize; +use std::collections::BTreeMap; +use std::path::Path; +#[cfg(test)] +use std::sync::Arc; + +#[derive(Deserialize)] +pub(crate) struct Params { + pub uri: String, + pub labels: Vec