Skip to content

Commit

Permalink
reorder editor cursor painting order
Browse files Browse the repository at this point in the history
fix #3271
  • Loading branch information
dzhou121 committed Jun 6, 2024
1 parent a9c1739 commit f6e0e20
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ lapce-core = { path = "./lapce-core" }
lapce-rpc = { path = "./lapce-rpc" }
lapce-proxy = { path = "./lapce-proxy" }

floem-editor-core = { git = "https://github.com/lapce/floem", rev = "f178d220309dbaa74ebb7447c78a8b2b7660053c", features = ["serde"] }
# floem-editor-core = { path = "../workspaces/floem/editor-core/", features = ["serde"] }
floem-editor-core = { git = "https://github.com/lapce/floem", rev = "e5d2ded9b7c35d0ef357d966bc688b3904da2770", features = ["serde"] }
# floem-editor-core = { path = "../floem/editor-core/", features = ["serde"] }

[patch.crates-io]
# Temporarily patch lsp-types with a version that adds message-type debug
Expand Down
4 changes: 2 additions & 2 deletions lapce-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ zip = { version = "0.6.6", default-features = false, features = ["d
percent-encoding = { version = "2.3.1" }

[dependencies.floem]
# path = "../../workspaces/floem"
# path = "../../floem"
git = "https://github.com/lapce/floem"
rev = "f178d220309dbaa74ebb7447c78a8b2b7660053c"
rev = "e5d2ded9b7c35d0ef357d966bc688b3904da2770"
default-features = true
features = ["editor", "serde", "default-image-formats", "rfd-async-std"]

Expand Down
17 changes: 8 additions & 9 deletions lapce-app/src/editor/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ impl EditorView {
}
}

fn paint_cursor(
fn paint_current_line(
&self,
cx: &mut PaintCx,
is_local: bool,
Expand All @@ -404,14 +404,11 @@ impl EditorView {
let e_data = self.editor.clone();
let ed = e_data.editor.clone();
let cursor = self.editor.cursor();
let find_focus = self.editor.find_focus;
let config = self.editor.common.config;

let config = config.get_untracked();
let line_height = config.editor.line_height() as f64;
let viewport = self.viewport.get_untracked();
let is_active =
self.is_active.get_untracked() && !find_focus.get_untracked();

let current_line_color = ed.es.with_untracked(EditorStyle::current_line);

Expand Down Expand Up @@ -472,10 +469,6 @@ impl EditorView {
}
}
}

FloemEditorView::paint_selection(cx, &ed, screen_lines);

FloemEditorView::paint_cursor_caret(cx, &ed, is_active, screen_lines);
});
}

Expand Down Expand Up @@ -1097,6 +1090,9 @@ impl View for EditorView {
let config = e_data.common.config.get_untracked();
let doc = e_data.doc();
let is_local = doc.content.with_untracked(|content| content.is_local());
let find_focus = self.editor.find_focus;
let is_active =
self.is_active.get_untracked() && !find_focus.get_untracked();

// We repeatedly get the screen lines because we don't currently carefully manage the
// paint functions to avoid potentially needing to recompute them, which could *maybe*
Expand All @@ -1107,14 +1103,17 @@ impl View for EditorView {
// I expect that most/all of the paint functions could restrict themselves to only what is
// within the active screen lines without issue.
let screen_lines = ed.screen_lines.get_untracked();
self.paint_cursor(cx, is_local, &screen_lines);
self.paint_current_line(cx, is_local, &screen_lines);
FloemEditorView::paint_selection(cx, ed, &screen_lines);
let screen_lines = ed.screen_lines.get_untracked();
self.paint_diff_sections(cx, viewport, &screen_lines, &config);
let screen_lines = ed.screen_lines.get_untracked();
self.paint_find(cx, &screen_lines);
let screen_lines = ed.screen_lines.get_untracked();
self.paint_bracket_highlights_scope_lines(cx, viewport, &screen_lines);
let screen_lines = ed.screen_lines.get_untracked();
FloemEditorView::paint_cursor_caret(cx, ed, is_active, &screen_lines);
let screen_lines = ed.screen_lines.get_untracked();
FloemEditorView::paint_text(cx, ed, viewport, &screen_lines);
let screen_lines = ed.screen_lines.get_untracked();
self.paint_sticky_headers(cx, viewport, &screen_lines);
Expand Down

0 comments on commit f6e0e20

Please sign in to comment.