Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
dbd6a9c
WIP
RemcoSmitsDev Apr 9, 2025
de1c708
debugger: Add support for inline values through language servers
RemcoSmitsDev Apr 10, 2025
9908867
Merge branch 'main' into debugger-inline-value
RemcoSmitsDev Apr 13, 2025
8ac838e
Remove added whitespace
RemcoSmitsDev Apr 13, 2025
353e1d6
Fix panic caused by one based row count
RemcoSmitsDev Apr 13, 2025
2d0b426
Clipppyyy
RemcoSmitsDev Apr 13, 2025
fe65a1e
Use correct rpc proto handler for InlineValue request
RemcoSmitsDev Apr 13, 2025
482e7f5
Wip make treesitter work :)
RemcoSmitsDev Apr 16, 2025
300ac14
WIP invalidate
RemcoSmitsDev Apr 16, 2025
e72534d
Invalidate debugger inline values when debugger state has changed
Anthony-Eid Apr 16, 2025
47d652e
WIP
Anthony-Eid Apr 16, 2025
ee87975
Start work on decouping inline values from inlay hints
Anthony-Eid Apr 17, 2025
91497ce
Merge branch 'main' into debugger-inline-value
RemcoSmitsDev Apr 18, 2025
dbdbb74
Only get all variables that belong to the stack frame
RemcoSmitsDev Apr 20, 2025
978e9c7
Only show inline values before the active debug line
RemcoSmitsDev Apr 20, 2025
c06cc84
Get inline values to work with it's own caching system
Anthony-Eid Apr 23, 2025
a1cec8d
Update debugger inline values when selecting stack frames
Anthony-Eid Apr 23, 2025
c95e154
Show inline values only within function scope of active stack frame
Anthony-Eid Apr 23, 2025
468daad
Add rust inline values support for debugging
Anthony-Eid Apr 23, 2025
f087787
Add inline value setting
Anthony-Eid Apr 23, 2025
52d3905
Remove inline values lsp request
Anthony-Eid Apr 23, 2025
4d2cb87
Some more cleanup
Anthony-Eid Apr 23, 2025
c9d58cd
Merge with main
Anthony-Eid Apr 23, 2025
5a0d5b7
Don't invalidate inline values when fetching variables
Anthony-Eid Apr 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ livekit_api = { path = "crates/livekit_api" }
livekit_client = { path = "crates/livekit_client" }
lmstudio = { path = "crates/lmstudio" }
lsp = { path = "crates/lsp" }
lsp-types = { git = "https://github.com/zed-industries/lsp-types", rev = "c9c189f1c5dd53c624a419ce35bc77ad6a908d18" }
markdown = { path = "crates/markdown" }
markdown_preview = { path = "crates/markdown_preview" }
media = { path = "crates/media" }
Expand Down
4 changes: 4 additions & 0 deletions crates/collab/src/tests/editor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
store.update_user_settings::<AllLanguageSettings>(cx, |settings| {
settings.defaults.inlay_hints = Some(InlayHintSettings {
enabled: true,
show_value_hints: true,
edit_debounce_ms: 0,
scroll_debounce_ms: 0,
show_type_hints: true,
Expand All @@ -1559,6 +1560,7 @@ async fn test_mutual_editor_inlay_hint_cache_update(
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<AllLanguageSettings>(cx, |settings| {
settings.defaults.inlay_hints = Some(InlayHintSettings {
show_value_hints: true,
enabled: true,
edit_debounce_ms: 0,
scroll_debounce_ms: 0,
Expand Down Expand Up @@ -1778,6 +1780,7 @@ async fn test_inlay_hint_refresh_is_forwarded(
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<AllLanguageSettings>(cx, |settings| {
settings.defaults.inlay_hints = Some(InlayHintSettings {
show_value_hints: true,
enabled: false,
edit_debounce_ms: 0,
scroll_debounce_ms: 0,
Expand All @@ -1794,6 +1797,7 @@ async fn test_inlay_hint_refresh_is_forwarded(
SettingsStore::update_global(cx, |store, cx| {
store.update_user_settings::<AllLanguageSettings>(cx, |settings| {
settings.defaults.inlay_hints = Some(InlayHintSettings {
show_value_hints: true,
enabled: true,
edit_debounce_ms: 0,
scroll_debounce_ms: 0,
Expand Down
1 change: 1 addition & 0 deletions crates/dap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ gpui.workspace = true
http_client.workspace = true
language.workspace = true
log.workspace = true
lsp-types.workspace = true
node_runtime.workspace = true
parking_lot.workspace = true
paths.workspace = true
Expand Down
9 changes: 9 additions & 0 deletions crates/dap/src/adapters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,10 @@ pub async fn fetch_latest_adapter_version_from_github(
})
}

pub trait InlineValueProvider {
fn provide(&self, variables: Vec<(String, lsp_types::Range)>) -> Vec<lsp_types::InlineValue>;
}

#[async_trait(?Send)]
pub trait DebugAdapter: 'static + Send + Sync {
fn name(&self) -> DebugAdapterName;
Expand Down Expand Up @@ -373,7 +377,12 @@ pub trait DebugAdapter: 'static + Send + Sync {
user_installed_path: Option<PathBuf>,
cx: &mut AsyncApp,
) -> Result<DebugAdapterBinary>;

fn inline_value_provider(&self) -> Option<Box<dyn InlineValueProvider>> {
None
}
}

#[cfg(any(test, feature = "test-support"))]
pub struct FakeAdapter {}

Expand Down
1 change: 1 addition & 0 deletions crates/dap_adapters/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ async-trait.workspace = true
dap.workspace = true
gpui.workspace = true
language.workspace = true
lsp-types.workspace = true
paths.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand Down
23 changes: 22 additions & 1 deletion crates/dap_adapters/src/codelldb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{collections::HashMap, path::PathBuf, sync::OnceLock};

use anyhow::{Result, bail};
use async_trait::async_trait;
use dap::adapters::latest_github_release;
use dap::adapters::{InlineValueProvider, latest_github_release};
use gpui::AsyncApp;
use task::{DebugRequest, DebugTaskDefinition};

Expand Down Expand Up @@ -150,4 +150,25 @@ impl DebugAdapter for CodeLldbDebugAdapter {
connection: None,
})
}

fn inline_value_provider(&self) -> Option<Box<dyn InlineValueProvider>> {
Some(Box::new(CodeLldbInlineValueProvider))
}
}

struct CodeLldbInlineValueProvider;

impl InlineValueProvider for CodeLldbInlineValueProvider {
fn provide(&self, variables: Vec<(String, lsp_types::Range)>) -> Vec<lsp_types::InlineValue> {
variables
.into_iter()
.map(|(variable, range)| {
lsp_types::InlineValue::VariableLookup(lsp_types::InlineValueVariableLookup {
range,
variable_name: Some(variable),
case_sensitive_lookup: true,
})
})
.collect()
}
}
32 changes: 31 additions & 1 deletion crates/dap_adapters/src/python.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::*;
use dap::{DebugRequest, StartDebuggingRequestArguments};
use dap::{StartDebuggingRequestArguments, adapters::InlineValueProvider};
use gpui::AsyncApp;
use std::{collections::HashMap, ffi::OsStr, path::PathBuf};
use task::DebugTaskDefinition;
Expand Down Expand Up @@ -160,4 +160,34 @@ impl DebugAdapter for PythonDebugAdapter {
request_args: self.request_args(config),
})
}

fn inline_value_provider(&self) -> Option<Box<dyn InlineValueProvider>> {
Some(Box::new(PythonInlineValueProvider))
}
}

struct PythonInlineValueProvider;

impl InlineValueProvider for PythonInlineValueProvider {
fn provide(&self, variables: Vec<(String, lsp_types::Range)>) -> Vec<lsp_types::InlineValue> {
variables
.into_iter()
.map(|(variable, range)| {
if variable.contains(".") || variable.contains("[") {
lsp_types::InlineValue::EvaluatableExpression(
lsp_types::InlineValueEvaluatableExpression {
range,
expression: Some(variable),
},
)
} else {
lsp_types::InlineValue::VariableLookup(lsp_types::InlineValueVariableLookup {
range,
variable_name: Some(variable),
case_sensitive_lookup: true,
})
}
})
.collect()
}
}
2 changes: 1 addition & 1 deletion crates/debugger_ui/src/debugger_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ pub fn init(cx: &mut App) {
let stack_id = state.selected_stack_frame_id(cx);

state.session().update(cx, |session, cx| {
session.evaluate(text, None, stack_id, None, cx);
session.evaluate(text, None, stack_id, None, cx).detach();
});
});
Some(())
Expand Down
18 changes: 10 additions & 8 deletions crates/debugger_ui/src/session/running/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,16 @@ impl Console {
expression
});

self.session.update(cx, |state, cx| {
state.evaluate(
expression,
Some(dap::EvaluateArgumentsContext::Variables),
self.stack_frame_list.read(cx).selected_stack_frame_id(),
None,
cx,
);
self.session.update(cx, |session, cx| {
session
.evaluate(
expression,
Some(dap::EvaluateArgumentsContext::Variables),
self.stack_frame_list.read(cx).selected_stack_frame_id(),
None,
cx,
)
.detach();
});
}

Expand Down
14 changes: 13 additions & 1 deletion crates/debugger_ui/src/session/running/stack_frame_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use gpui::{
};

use language::PointUtf16;
use project::debugger::breakpoint_store::ActiveStackFrame;
use project::debugger::session::{Session, SessionEvent, StackFrame};
use project::{ProjectItem, ProjectPath};
use ui::{Scrollbar, ScrollbarState, Tooltip, prelude::*};
Expand Down Expand Up @@ -265,6 +266,7 @@ impl StackFrameList {
return Task::ready(Err(anyhow!("Project path not found")));
};

let stack_frame_id = stack_frame.id;
cx.spawn_in(window, async move |this, cx| {
let (worktree, relative_path) = this
.update(cx, |this, cx| {
Expand Down Expand Up @@ -313,12 +315,22 @@ impl StackFrameList {
.await?;

this.update(cx, |this, cx| {
let Some(thread_id) = this.state.read_with(cx, |state, _| state.thread_id)? else {
return Err(anyhow!("No selected thread ID found"));
};

this.workspace.update(cx, |workspace, cx| {
let breakpoint_store = workspace.project().read(cx).breakpoint_store();

breakpoint_store.update(cx, |store, cx| {
store.set_active_position(
(this.session.read(cx).session_id(), abs_path, position),
ActiveStackFrame {
session_id: this.session.read(cx).session_id(),
thread_id,
stack_frame_id,
path: abs_path,
position,
},
cx,
);
})
Expand Down
1 change: 1 addition & 0 deletions crates/editor/src/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ actions!(
OpenGitBlameCommit,
ToggleIndentGuides,
ToggleInlayHints,
ToggleInlineValues,
ToggleInlineDiagnostics,
ToggleEditPrediction,
ToggleLineNumbers,
Expand Down
9 changes: 9 additions & 0 deletions crates/editor/src/display_map/inlay_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ impl Inlay {
text: text.into(),
}
}

pub fn debugger_hint<T: Into<Rope>>(id: usize, position: Anchor, text: T) -> Self {
Self {
id: InlayId::DebuggerValue(id),
position,
text: text.into(),
}
}
}

impl sum_tree::Item for Transform {
Expand Down Expand Up @@ -287,6 +295,7 @@ impl<'a> Iterator for InlayChunks<'a> {
})
}
InlayId::Hint(_) => self.highlight_styles.inlay_hint,
InlayId::DebuggerValue(_) => self.highlight_styles.inlay_hint,
};
let next_inlay_highlight_endpoint;
let offset_in_inlay = self.output_offset - self.transforms.start().0;
Expand Down
Loading