|
|
@ -15,6 +15,7 @@ use helix_core::{
|
|
|
|
unicode::width::UnicodeWidthStr,
|
|
|
|
unicode::width::UnicodeWidthStr,
|
|
|
|
LineEnding, Position, Range, Selection,
|
|
|
|
LineEnding, Position, Range, Selection,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
use helix_dap::{SourceBreakpoint, StackFrame};
|
|
|
|
use helix_view::{
|
|
|
|
use helix_view::{
|
|
|
|
document::Mode,
|
|
|
|
document::Mode,
|
|
|
|
editor::LineNumber,
|
|
|
|
editor::LineNumber,
|
|
|
@ -24,7 +25,8 @@ use helix_view::{
|
|
|
|
keyboard::{KeyCode, KeyModifiers},
|
|
|
|
keyboard::{KeyCode, KeyModifiers},
|
|
|
|
Document, Editor, Theme, View,
|
|
|
|
Document, Editor, Theme, View,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use std::borrow::Cow;
|
|
|
|
use std::{borrow::Cow, sync::Arc};
|
|
|
|
|
|
|
|
use tokio::sync::Mutex;
|
|
|
|
|
|
|
|
|
|
|
|
use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
|
|
|
|
use crossterm::event::{Event, MouseButton, MouseEvent, MouseEventKind};
|
|
|
|
use tui::buffer::Buffer as Surface;
|
|
|
|
use tui::buffer::Buffer as Surface;
|
|
|
@ -71,7 +73,7 @@ impl EditorView {
|
|
|
|
is_focused: bool,
|
|
|
|
is_focused: bool,
|
|
|
|
loader: &syntax::Loader,
|
|
|
|
loader: &syntax::Loader,
|
|
|
|
config: &helix_view::editor::Config,
|
|
|
|
config: &helix_view::editor::Config,
|
|
|
|
debugger: Option<&helix_dap::Client>,
|
|
|
|
debugger: Option<Arc<Mutex<helix_dap::Client>>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
let inner = view.inner_area();
|
|
|
|
let inner = view.inner_area();
|
|
|
|
let area = view.area;
|
|
|
|
let area = view.area;
|
|
|
@ -412,8 +414,9 @@ impl EditorView {
|
|
|
|
theme: &Theme,
|
|
|
|
theme: &Theme,
|
|
|
|
is_focused: bool,
|
|
|
|
is_focused: bool,
|
|
|
|
config: &helix_view::editor::Config,
|
|
|
|
config: &helix_view::editor::Config,
|
|
|
|
debugger: Option<&helix_dap::Client>,
|
|
|
|
debugger: Option<Arc<Mutex<helix_dap::Client>>>,
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
|
|
|
|
use helix_lsp::block_on;
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
let text = doc.text().slice(..);
|
|
|
|
let last_line = view.last_line(doc);
|
|
|
|
let last_line = view.last_line(doc);
|
|
|
|
|
|
|
|
|
|
|
@ -442,9 +445,15 @@ impl EditorView {
|
|
|
|
.map(|range| range.cursor_line(text))
|
|
|
|
.map(|range| range.cursor_line(text))
|
|
|
|
.collect();
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
|
|
let breakpoints = doc
|
|
|
|
let mut breakpoints: Option<Vec<SourceBreakpoint>> = None;
|
|
|
|
.path()
|
|
|
|
let mut stack_pointer: Option<StackFrame> = None;
|
|
|
|
.and_then(|path| debugger.and_then(|debugger| debugger.breakpoints.get(path)));
|
|
|
|
if let Some(debugger) = debugger {
|
|
|
|
|
|
|
|
if let Some(path) = doc.path() {
|
|
|
|
|
|
|
|
let dbg = block_on(debugger.lock());
|
|
|
|
|
|
|
|
breakpoints = dbg.breakpoints.get(path).and_then(|bps| Some(bps.clone()));
|
|
|
|
|
|
|
|
stack_pointer = dbg.stack_pointer.clone()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
|
|
|
|
for (i, line) in (view.offset.row..(last_line + 1)).enumerate() {
|
|
|
|
use helix_core::diagnostic::Severity;
|
|
|
|
use helix_core::diagnostic::Severity;
|
|
|
@ -465,12 +474,23 @@ impl EditorView {
|
|
|
|
|
|
|
|
|
|
|
|
let selected = cursors.contains(&line);
|
|
|
|
let selected = cursors.contains(&line);
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(_breakpoint) = breakpoints.and_then(|breakpoints| {
|
|
|
|
if let Some(bps) = breakpoints.as_ref() {
|
|
|
|
breakpoints
|
|
|
|
if let Some(_) = bps.iter().find(|breakpoint| breakpoint.line == line) {
|
|
|
|
.iter()
|
|
|
|
surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, warning);
|
|
|
|
.find(|breakpoint| breakpoint.line == line)
|
|
|
|
}
|
|
|
|
}) {
|
|
|
|
}
|
|
|
|
surface.set_stringn(viewport.x, viewport.y + i as u16, "▲", 1, warning);
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(sp) = stack_pointer.as_ref() {
|
|
|
|
|
|
|
|
if let Some(src) = sp.source.as_ref() {
|
|
|
|
|
|
|
|
if doc
|
|
|
|
|
|
|
|
.path()
|
|
|
|
|
|
|
|
.and_then(|path| Some(src.path == Some(path.clone())))
|
|
|
|
|
|
|
|
.unwrap_or(false)
|
|
|
|
|
|
|
|
&& sp.line == line
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
surface.set_stringn(viewport.x, viewport.y + i as u16, "⇒", 1, warning);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let text = if line == last_line && !draw_last {
|
|
|
|
let text = if line == last_line && !draw_last {
|
|
|
@ -1023,7 +1043,10 @@ impl Component for EditorView {
|
|
|
|
for (view, is_focused) in cx.editor.tree.views() {
|
|
|
|
for (view, is_focused) in cx.editor.tree.views() {
|
|
|
|
let doc = cx.editor.document(view.doc).unwrap();
|
|
|
|
let doc = cx.editor.document(view.doc).unwrap();
|
|
|
|
let loader = &cx.editor.syn_loader;
|
|
|
|
let loader = &cx.editor.syn_loader;
|
|
|
|
let debugger = cx.editor.debugger.as_ref();
|
|
|
|
let mut dbg: Option<Arc<Mutex<helix_dap::Client>>> = None;
|
|
|
|
|
|
|
|
if let Some(debugger) = &cx.editor.debugger {
|
|
|
|
|
|
|
|
dbg = Some(Arc::clone(&debugger));
|
|
|
|
|
|
|
|
}
|
|
|
|
self.render_view(
|
|
|
|
self.render_view(
|
|
|
|
doc,
|
|
|
|
doc,
|
|
|
|
view,
|
|
|
|
view,
|
|
|
@ -1033,7 +1056,7 @@ impl Component for EditorView {
|
|
|
|
is_focused,
|
|
|
|
is_focused,
|
|
|
|
loader,
|
|
|
|
loader,
|
|
|
|
&cx.editor.config,
|
|
|
|
&cx.editor.config,
|
|
|
|
debugger,
|
|
|
|
dbg,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|