From cf7237d0b920eeb7d887c192bc46c44990cc9b68 Mon Sep 17 00:00:00 2001 From: Dmitry Sharshakov Date: Fri, 3 Sep 2021 23:11:06 +0300 Subject: [PATCH] compat: make thread IDs signed Delve needs it --- helix-dap/src/client.rs | 18 +++++++++--------- helix-dap/src/types.rs | 20 ++++++++++---------- helix-term/src/commands/dap.rs | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/helix-dap/src/client.rs b/helix-dap/src/client.rs index 9f274002..e1791cd1 100644 --- a/helix-dap/src/client.rs +++ b/helix-dap/src/client.rs @@ -28,9 +28,9 @@ pub struct Client { request_counter: AtomicU64, pub caps: Option, // thread_id -> frames - pub stack_frames: HashMap>, - pub thread_states: HashMap, - pub thread_id: Option, + pub stack_frames: HashMap>, + pub thread_states: HashMap, + pub thread_id: Option, /// Currently active frame for the current thread. pub active_frame: Option, } @@ -298,7 +298,7 @@ pub async fn configuration_done(&mut self) -> Result<()> { self.request::(()).await } - pub async fn continue_thread(&mut self, thread_id: usize) -> Result> { + pub async fn continue_thread(&mut self, thread_id: isize) -> Result> { let args = requests::ContinueArguments { thread_id }; let response = self.request::(args).await?; @@ -307,7 +307,7 @@ pub async fn continue_thread(&mut self, thread_id: usize) -> Result pub async fn stack_trace( &mut self, - thread_id: usize, + thread_id: isize, ) -> Result<(Vec, Option)> { let args = requests::StackTraceArguments { thread_id, @@ -345,7 +345,7 @@ pub async fn variables(&mut self, variables_reference: usize) -> Result Result<()> { + pub async fn step_in(&mut self, thread_id: isize) -> Result<()> { let args = requests::StepInArguments { thread_id, target_id: None, @@ -355,7 +355,7 @@ pub async fn step_in(&mut self, thread_id: usize) -> Result<()> { self.request::(args).await } - pub async fn step_out(&mut self, thread_id: usize) -> Result<()> { + pub async fn step_out(&mut self, thread_id: isize) -> Result<()> { let args = requests::StepOutArguments { thread_id, granularity: None, @@ -364,7 +364,7 @@ pub async fn step_out(&mut self, thread_id: usize) -> Result<()> { self.request::(args).await } - pub async fn next(&mut self, thread_id: usize) -> Result<()> { + pub async fn next(&mut self, thread_id: isize) -> Result<()> { let args = requests::NextArguments { thread_id, granularity: None, @@ -373,7 +373,7 @@ pub async fn next(&mut self, thread_id: usize) -> Result<()> { self.request::(args).await } - pub async fn pause(&mut self, thread_id: usize) -> Result<()> { + pub async fn pause(&mut self, thread_id: isize) -> Result<()> { let args = requests::PauseArguments { thread_id }; self.request::(args).await diff --git a/helix-dap/src/types.rs b/helix-dap/src/types.rs index c1781243..3af29922 100644 --- a/helix-dap/src/types.rs +++ b/helix-dap/src/types.rs @@ -157,7 +157,7 @@ pub struct StackFrame { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Thread { - pub id: usize, + pub id: isize, pub name: String, } @@ -317,7 +317,7 @@ impl Request for SetBreakpoints { #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct ContinueArguments { - pub thread_id: usize, + pub thread_id: isize, } #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] @@ -338,7 +338,7 @@ impl Request for Continue { #[derive(Debug, Default, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StackTraceArguments { - pub thread_id: usize, + pub thread_id: isize, pub start_frame: Option, pub levels: Option, pub format: Option, @@ -424,7 +424,7 @@ impl Request for Variables { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StepInArguments { - pub thread_id: usize, + pub thread_id: isize, pub target_id: Option, pub granularity: Option, } @@ -441,7 +441,7 @@ impl Request for StepIn { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct StepOutArguments { - pub thread_id: usize, + pub thread_id: isize, pub granularity: Option, } @@ -457,7 +457,7 @@ impl Request for StepOut { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct NextArguments { - pub thread_id: usize, + pub thread_id: isize, pub granularity: Option, } @@ -473,7 +473,7 @@ impl Request for Next { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct PauseArguments { - pub thread_id: usize, + pub thread_id: isize, } #[derive(Debug)] @@ -551,7 +551,7 @@ pub enum Event { pub struct Stopped { pub reason: String, pub description: Option, - pub thread_id: Option, + pub thread_id: Option, pub preserve_focus_hint: Option, pub text: Option, pub all_threads_stopped: Option, @@ -561,7 +561,7 @@ pub struct Stopped { #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] #[serde(rename_all = "camelCase")] pub struct Continued { - pub thread_id: usize, + pub thread_id: isize, pub all_threads_continued: Option, } @@ -581,7 +581,7 @@ pub struct Terminated { #[serde(rename_all = "camelCase")] pub struct Thread { pub reason: String, - pub thread_id: usize, + pub thread_id: isize, } #[derive(Debug, PartialEq, Clone, Deserialize, Serialize)] diff --git a/helix-term/src/commands/dap.rs b/helix-term/src/commands/dap.rs index 6b9b06b2..082e2c7a 100644 --- a/helix-term/src/commands/dap.rs +++ b/helix-term/src/commands/dap.rs @@ -29,7 +29,7 @@ pub fn resume_application(debugger: &mut Client) { debugger.thread_id = None; } -pub async fn select_thread_id(editor: &mut Editor, thread_id: usize, force: bool) { +pub async fn select_thread_id(editor: &mut Editor, thread_id: isize, force: bool) { let debugger = match &mut editor.debugger { Some(debugger) => debugger, None => return,