Skip to content

Commit ab18085

Browse files
ConradIrwinAnthony-Eidcole-miller
authored
Debug console tweaks (#29586)
Closes #ISSUE Release Notes: - N/A --------- Co-authored-by: Anthony Eid <hello@anthonyeid.me> Co-authored-by: Cole Miller <m@cole-miller.net>
1 parent 2beefc8 commit ab18085

File tree

4 files changed

+135
-149
lines changed

4 files changed

+135
-149
lines changed

crates/debugger_ui/src/session/running/console.rs

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ impl Console {
4545
let mut editor = Editor::multi_line(window, cx);
4646
editor.move_to_end(&editor::actions::MoveToEnd, window, cx);
4747
editor.set_read_only(true);
48-
editor.set_show_gutter(true, cx);
48+
editor.set_show_gutter(false, cx);
4949
editor.set_show_runnables(false, cx);
5050
editor.set_show_breakpoints(false, cx);
5151
editor.set_show_code_actions(false, cx);
@@ -57,6 +57,8 @@ impl Console {
5757
editor.set_show_wrap_guides(false, cx);
5858
editor.set_show_indent_guides(false, cx);
5959
editor.set_show_edit_predictions(Some(false), window, cx);
60+
editor.set_use_modal_editing(false);
61+
editor.set_soft_wrap_mode(language::language_settings::SoftWrap::EditorWidth, cx);
6062
editor
6163
});
6264
let focus_handle = cx.focus_handle();
@@ -146,6 +148,23 @@ impl Console {
146148
expression
147149
});
148150

151+
self.add_messages(
152+
[OutputEvent {
153+
category: None,
154+
output: format!("> {expression}"),
155+
group: None,
156+
variables_reference: None,
157+
source: None,
158+
line: None,
159+
column: None,
160+
data: None,
161+
location_reference: None,
162+
}]
163+
.iter(),
164+
window,
165+
cx,
166+
);
167+
149168
self.session.update(cx, |session, cx| {
150169
session
151170
.evaluate(
@@ -160,6 +179,10 @@ impl Console {
160179
}
161180

162181
fn render_console(&self, cx: &Context<Self>) -> impl IntoElement {
182+
EditorElement::new(&self.console, self.editor_style(cx))
183+
}
184+
185+
fn editor_style(&self, cx: &Context<Self>) -> EditorStyle {
163186
let settings = ThemeSettings::get_global(cx);
164187
let text_style = TextStyle {
165188
color: if self.console.read(cx).read_only(cx) {
@@ -174,44 +197,16 @@ impl Console {
174197
line_height: relative(settings.buffer_line_height.value()),
175198
..Default::default()
176199
};
177-
178-
EditorElement::new(
179-
&self.console,
180-
EditorStyle {
181-
background: cx.theme().colors().editor_background,
182-
local_player: cx.theme().players().local(),
183-
text: text_style,
184-
..Default::default()
185-
},
186-
)
200+
EditorStyle {
201+
background: cx.theme().colors().editor_background,
202+
local_player: cx.theme().players().local(),
203+
text: text_style,
204+
..Default::default()
205+
}
187206
}
188207

189208
fn render_query_bar(&self, cx: &Context<Self>) -> impl IntoElement {
190-
let settings = ThemeSettings::get_global(cx);
191-
let text_style = TextStyle {
192-
color: if self.console.read(cx).read_only(cx) {
193-
cx.theme().colors().text_disabled
194-
} else {
195-
cx.theme().colors().text
196-
},
197-
font_family: settings.ui_font.family.clone(),
198-
font_features: settings.ui_font.features.clone(),
199-
font_fallbacks: settings.ui_font.fallbacks.clone(),
200-
font_size: TextSize::Editor.rems(cx).into(),
201-
font_weight: settings.ui_font.weight,
202-
line_height: relative(1.3),
203-
..Default::default()
204-
};
205-
206-
EditorElement::new(
207-
&self.query_bar,
208-
EditorStyle {
209-
background: cx.theme().colors().editor_background,
210-
local_player: cx.theme().players().local(),
211-
text: text_style,
212-
..Default::default()
213-
},
214-
)
209+
EditorElement::new(&self.query_bar, self.editor_style(cx))
215210
}
216211
}
217212

crates/project/src/debugger/dap_command.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rpc::proto;
1414
use serde_json::Value;
1515
use util::ResultExt;
1616

17-
pub(crate) trait LocalDapCommand: 'static + Send + Sync + std::fmt::Debug {
17+
pub trait LocalDapCommand: 'static + Send + Sync + std::fmt::Debug {
1818
type Response: 'static + Send + std::fmt::Debug;
1919
type DapRequest: 'static + Send + dap::requests::Request;
2020

@@ -30,7 +30,7 @@ pub(crate) trait LocalDapCommand: 'static + Send + Sync + std::fmt::Debug {
3030
) -> Result<Self::Response>;
3131
}
3232

33-
pub(crate) trait DapCommand: LocalDapCommand {
33+
pub trait DapCommand: LocalDapCommand {
3434
type ProtoRequest: 'static + Send;
3535
type ProtoResponse: 'static + Send;
3636
const CACHEABLE: bool = false;

crates/project/src/debugger/dap_store.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::{
22
breakpoint_store::BreakpointStore,
3+
dap_command::EvaluateCommand,
34
locators,
45
session::{self, Session, SessionStateEvent},
56
};
@@ -897,19 +898,18 @@ impl DapStore {
897898
.clone()
898899
.unwrap_or_else(|| snapshot.text_for_range(range.clone()).collect());
899900

900-
let Ok(eval_task) = session.update(cx, |session, cx| {
901-
session.evaluate(
901+
let Ok(eval_task) = session.update(cx, |session, _| {
902+
session.mode.request_dap(EvaluateCommand {
902903
expression,
903-
Some(EvaluateArgumentsContext::Variables),
904-
Some(stack_frame_id),
905-
None,
906-
cx,
907-
)
904+
frame_id: Some(stack_frame_id),
905+
source: None,
906+
context: Some(EvaluateArgumentsContext::Variables),
907+
})
908908
}) else {
909909
continue;
910910
};
911911

912-
if let Some(response) = eval_task.await {
912+
if let Some(response) = eval_task.await.log_err() {
913913
inlay_hints.push(InlayHint {
914914
position: snapshot.anchor_after(range.end),
915915
label: InlayHintLabel::String(format!(": {}", response.result)),

0 commit comments

Comments
 (0)