on master help sign in
editor: select a range if stack pointer has an end
d0b0c9bDmitry Sharshakov
Cargo.lock+1
@@ -388,6 +388,7 @@ dependencies = [
388 "serde_json",
388 "serde_json",
389 "signal-hook",
389 "signal-hook",
390 "signal-hook-tokio",
390 "signal-hook-tokio",
391+ "smallvec",
391 "tokio",
392 "tokio",
392 "tokio-stream",
393 "tokio-stream",
393 "toml",
394 "toml",
helix-term/Cargo.toml+2
@@ -56,5 +56,7 @@ toml = "0.5"
56serde_json = "1.0"
56serde_json = "1.0"
57serde = { version = "1.0", features = ["derive"] }
57serde = { version = "1.0", features = ["derive"] }
58
58
59+smallvec = "1.4"
60+
59[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
61[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
60signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
62signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
helix-term/src/application.rs+17−4
@@ -1,4 +1,4 @@
1−use helix_core::{syntax, Selection};
1+use helix_core::{syntax, Range, Selection};
2use helix_dap::Payload;
2use helix_dap::Payload;
3use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
3use helix_lsp::{lsp, util::lsp_pos_to_pos, LspProgressMap};
4use helix_view::{theme, Editor};
4use helix_view::{theme, Editor};
@@ -13,7 +13,7 @@ use crate::{
13};
13};
14
14
15use log::error;
15use log::error;
16−
16+use smallvec::smallvec;
17use std::{
17use std::{
18 io::{stdout, Write},
18 io::{stdout, Write},
19 sync::Arc,
19 sync::Arc,
@@ -309,19 +309,32 @@ impl Application {
309 }),
309 }),
310 line,
310 line,
311 column,
311 column,
312+ end_line,
313+ end_column,
312 ..
314 ..
313 }) = &debugger.stack_pointer
315 }) = &debugger.stack_pointer
314 {
316 {
315 let path = src.clone();
317 let path = src.clone();
316 let line = *line;
318 let line = *line;
317 let column = *column;
319 let column = *column;
320+ let end_line = *end_line;
321+ let end_column = *end_column;
318 self.editor
322 self.editor
319 .open(path, helix_view::editor::Action::Replace)
323 .open(path, helix_view::editor::Action::Replace)
320 .unwrap();
324 .unwrap();
321
325
322 let (view, doc) = current!(self.editor);
326 let (view, doc) = current!(self.editor);
323− let pos = doc.text().line_to_char(line - 1) + column;
327+ let start = doc.text().line_to_char(line - 1) + column;
328+ if let Some(end_line) = end_line {
329+ let end =
330+ doc.text().line_to_char(end_line - 1) + end_column.unwrap_or(0);
331+ doc.set_selection(
332+ view.id,
333+ Selection::new(smallvec![Range::new(start, end)], 0),
334+ );
335+ } else {
324− doc.set_selection(view.id, Selection::point(pos));
336+ doc.set_selection(view.id, Selection::point(start));
337+ }
325 align_view(doc, view, Align::Center);
338 align_view(doc, view, Align::Center);
326 }
339 }
327 self.editor.set_status(status);
340 self.editor.set_status(status);