diff --git a/crates/terminal/README.md b/crates/terminal/README.md index c1e64726b26f64054f9156aabf7132005098927a..99ab583ebbf8590b0137c0acc066ba2f7f261313 100644 --- a/crates/terminal/README.md +++ b/crates/terminal/README.md @@ -1,8 +1,9 @@ Design notes: This crate is split into two conceptual halves: -- The terminal.rs file and the ./src/mappings/ folder, these contain the code for interacting with Alacritty and maintaining the pty event loop. Some behavior in this file is constrained by terminal protocols and standards. The Zed init function is also placed here. +- The terminal.rs file and the src/mappings/ folder, these contain the code for interacting with Alacritty and maintaining the pty event loop. Some behavior in this file is constrained by terminal protocols and standards. The Zed init function is also placed here. - Everything else. These other files integrate the `Terminal` struct created in terminal.rs into the rest of GPUI. The main entry point for GPUI is the terminal_view.rs file and the modal.rs file. Terminals are created externally, and so can fail in unexpected ways However, GPUI currently does not have an API for models than can fail to instantiate. `TerminalBuilder` solves this by using Rust's type system to split `Terminal` instantiation into a 2 step process: first attempt to create the file handles with `TerminalBuilder::new()`, check the result, then call `TerminalBuilder::subscribe(cx)` from within a model context. -The TerminalView struct abstracts over failed and successful terminals, and provides other constructs a standardized way of instantiating an always-successful terminal view. \ No newline at end of file +The TerminalView struct abstracts over failed and successful terminals, and provides a standardized way of instantiating an always-successful view of a terminal. + diff --git a/crates/terminal/src/connected_el.rs b/crates/terminal/src/connected_el.rs index 1a804b4154fb051f041e6afb988525cece8dc3e5..36d75e30b78aa493d7e49ea5520460f1dc77cc76 100644 --- a/crates/terminal/src/connected_el.rs +++ b/crates/terminal/src/connected_el.rs @@ -343,12 +343,14 @@ impl TerminalEl { text_fragment.width() }; + //Cursor should always surround as much of the text as possible, + //hence when on pixel boundaries round the origin down and the width up Some(( vec2f( - cursor_point.col() as f32 * size.cell_width(), - cursor_point.line() as f32 * size.line_height(), + (cursor_point.col() as f32 * size.cell_width()).floor(), + (cursor_point.line() as f32 * size.line_height()).floor(), ), - cursor_width, + cursor_width.ceil(), )) } else { None