aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands
diff options
context:
space:
mode:
authorGokul Soumya2022-12-25 05:54:09 +0000
committerBlaž Hrastnik2023-01-18 05:19:32 +0000
commit5c7db7aed54f52b3af6102517f81c9d70bb6d1fb (patch)
treea49faaa0ceb633c09b908bfe249d2f9b4a935680 /helix-term/src/commands
parentb2837ff3bea286ce7ccfba9b6fbcd861977caf83 (diff)
Replace menu::Item::{row, label} with format()
Diffstat (limited to 'helix-term/src/commands')
-rw-r--r--helix-term/src/commands/dap.rs8
-rw-r--r--helix-term/src/commands/lsp.rs16
2 files changed, 14 insertions, 10 deletions
diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs
index b182f28c..b3166e39 100644
--- a/helix-term/src/commands/dap.rs
+++ b/helix-term/src/commands/dap.rs
@@ -12,7 +12,7 @@ use helix_view::editor::Breakpoint;
use serde_json::{to_value, Value};
use tokio_stream::wrappers::UnboundedReceiverStream;
-use tui::text::Spans;
+use tui::{text::Spans, widgets::Row};
use std::collections::HashMap;
use std::future::Future;
@@ -25,7 +25,7 @@ use helix_view::handlers::dap::{breakpoints_changed, jump_to_stack_frame, select
impl ui::menu::Item for StackFrame {
type Data = ();
- fn label(&self, _data: &Self::Data) -> Spans {
+ fn format(&self, _data: &Self::Data) -> Row {
self.name.as_str().into() // TODO: include thread_states in the label
}
}
@@ -33,7 +33,7 @@ impl ui::menu::Item for StackFrame {
impl ui::menu::Item for DebugTemplate {
type Data = ();
- fn label(&self, _data: &Self::Data) -> Spans {
+ fn format(&self, _data: &Self::Data) -> Row {
self.name.as_str().into()
}
}
@@ -41,7 +41,7 @@ impl ui::menu::Item for DebugTemplate {
impl ui::menu::Item for Thread {
type Data = ThreadStates;
- fn label(&self, thread_states: &Self::Data) -> Spans {
+ fn format(&self, thread_states: &Self::Data) -> Row {
format!(
"{} ({})",
self.name,
diff --git a/helix-term/src/commands/lsp.rs b/helix-term/src/commands/lsp.rs
index 86b0c5fa..90b6d76c 100644
--- a/helix-term/src/commands/lsp.rs
+++ b/helix-term/src/commands/lsp.rs
@@ -5,7 +5,10 @@ use helix_lsp::{
util::{diagnostic_to_lsp_diagnostic, lsp_pos_to_pos, lsp_range_to_range, range_to_lsp_range},
OffsetEncoding,
};
-use tui::text::{Span, Spans};
+use tui::{
+ text::{Span, Spans},
+ widgets::Row,
+};
use super::{align_view, push_jump, Align, Context, Editor, Open};
@@ -46,7 +49,7 @@ impl ui::menu::Item for lsp::Location {
/// Current working directory.
type Data = PathBuf;
- fn label(&self, cwdir: &Self::Data) -> Spans {
+ fn format(&self, cwdir: &Self::Data) -> Row {
// The preallocation here will overallocate a few characters since it will account for the
// URL's scheme, which is not used most of the time since that scheme will be "file://".
// Those extra chars will be used to avoid allocating when writing the line number (in the
@@ -80,7 +83,7 @@ impl ui::menu::Item for lsp::SymbolInformation {
/// Path to currently focussed document
type Data = Option<lsp::Url>;
- fn label(&self, current_doc_path: &Self::Data) -> Spans {
+ fn format(&self, current_doc_path: &Self::Data) -> Row {
if current_doc_path.as_ref() == Some(&self.location.uri) {
self.name.as_str().into()
} else {
@@ -110,7 +113,7 @@ struct PickerDiagnostic {
impl ui::menu::Item for PickerDiagnostic {
type Data = (DiagnosticStyles, DiagnosticsFormat);
- fn label(&self, (styles, format): &Self::Data) -> Spans {
+ fn format(&self, (styles, format): &Self::Data) -> Row {
let mut style = self
.diag
.severity
@@ -149,6 +152,7 @@ impl ui::menu::Item for PickerDiagnostic {
Span::styled(&self.diag.message, style),
Span::styled(code, style),
])
+ .into()
}
}
@@ -467,7 +471,7 @@ pub fn workspace_diagnostics_picker(cx: &mut Context) {
impl ui::menu::Item for lsp::CodeActionOrCommand {
type Data = ();
- fn label(&self, _data: &Self::Data) -> Spans {
+ fn format(&self, _data: &Self::Data) -> Row {
match self {
lsp::CodeActionOrCommand::CodeAction(action) => action.title.as_str().into(),
lsp::CodeActionOrCommand::Command(command) => command.title.as_str().into(),
@@ -662,7 +666,7 @@ pub fn code_action(cx: &mut Context) {
impl ui::menu::Item for lsp::Command {
type Data = ();
- fn label(&self, _data: &Self::Data) -> Spans {
+ fn format(&self, _data: &Self::Data) -> Row {
self.title.as_str().into()
}
}