Code view:

A painting is a person's account of this edit as text, recorded independently of the node mapping - a rendering often has several equally defensible answers where the mapping has one. Deletions and insertions carry no position on the opposite side in a painting, so that panel draws no caret for them.

Before

1use std::{
2 cell::{Cell, RefCell},
3 rc::Rc,
4};
5
6use gpui::{Bounds, Point, Size, size};
7use terminal::Terminal;
8use ui::{Pixels, ScrollableHandle, px};
9
10#[derive(Debug)]
11struct ScrollHandleState {
12 line_height: Pixels,
…lines 13–42 unchanged (30 lines)
43 pub fn update(&self, terminal: &Terminal) {
44 *self.state.borrow_mut() = ScrollHandleState::new(terminal);
45 }
46}
47
48impl ScrollableHandle for TerminalScrollHandle {
49 fn max_offset(&self) -> Size<Pixels> {
50 let state = self.state.borrow();
51 size(
52 Pixels::ZERO,
53 state.total_lines.saturating_sub(state.viewport_lines) as f32 * state.line_height,
54 )
55 }
56
57 fn offset(&self) -> Point<Pixels> {
…lines 58–88 unchanged (31 lines)

After

1use std::{
2 cell::{Cell, RefCell},
3 rc::Rc,
4};
5
6use gpui::{Bounds, Point, point, size};
7use terminal::Terminal;
8use ui::{Pixels, ScrollableHandle, px};
9
10#[derive(Debug)]
11struct ScrollHandleState {
12 line_height: Pixels,
…lines 13–42 unchanged (30 lines)
43 pub fn update(&self, terminal: &Terminal) {
44 *self.state.borrow_mut() = ScrollHandleState::new(terminal);
45 }
46}
47
48impl ScrollableHandle for TerminalScrollHandle {
49 fn max_offset(&self) -> Point<Pixels> {
50 let state = self.state.borrow();
51 point(
52 Pixels::ZERO,
53 state.total_lines.saturating_sub(state.viewport_lines) as f32 * state.line_height,
54 )
55 }
56
57 fn offset(&self) -> Point<Pixels> {
…lines 58–88 unchanged (31 lines)

Before

source_file
use_declaration (+24 nodes collapsed)
use_declaration
use "use"
scoped_use_list
identifier "gpui"
:: "::"
use_list
{ "{"
identifier "Bounds"
, ","
identifier "Point"
, ","
identifier "Size"
, ","
identifier "size"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "terminal"
:: "::"
identifier "Terminal"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "ui"
:: "::"
use_list
{ "{"
identifier "Pixels"
, ","
identifier "ScrollableHandle"
, ","
identifier "px"
} "}"
; ";"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
) ")"
] "]"
struct_item (+26 nodes collapsed)
impl_item (+85 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
, ","
identifier "Clone"
) ")"
] "]"
struct_item (+45 nodes collapsed)
impl_item (+127 nodes collapsed)
impl_item
impl "impl"
type_identifier "ScrollableHandle"
for "for"
type_identifier "TerminalScrollHandle"
declaration_list
{ "{"
function_item
fn "fn"
identifier "max_offset"
parameters
( "("
self_parameter
& "&"
self "self"
) ")"
-> "->"
generic_type
type_identifier "Size"
type_arguments
< "<"
type_identifier "Pixels"
> ">"
block
{ "{"
let_declaration
let "let"
identifier "state"
= "="
call_expression
field_expression
field_expression
self "self"
. "."
field_identifier "state"
. "."
field_identifier "borrow"
arguments
( "("
) ")"
; ";"
call_expression
identifier "size"
arguments (+33 nodes collapsed)
} "}"
function_item (+94 nodes collapsed)
function_item (+136 nodes collapsed)
function_item (+90 nodes collapsed)
} "}"

After

source_file
use_declaration (+24 nodes collapsed)
use_declaration
use "use"
scoped_use_list
identifier "gpui"
:: "::"
use_list
{ "{"
identifier "Bounds"
, ","
identifier "Point"
, ","
identifier "point"
, ","
identifier "size"
} "}"
; ";"
use_declaration
use "use"
scoped_identifier
identifier "terminal"
:: "::"
identifier "Terminal"
; ";"
use_declaration
use "use"
scoped_use_list
identifier "ui"
:: "::"
use_list
{ "{"
identifier "Pixels"
, ","
identifier "ScrollableHandle"
, ","
identifier "px"
} "}"
; ";"
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
) ")"
] "]"
struct_item (+26 nodes collapsed)
impl_item (+85 nodes collapsed)
attribute_item
# "#"
[ "["
attribute
identifier "derive"
token_tree
( "("
identifier "Debug"
, ","
identifier "Clone"
) ")"
] "]"
struct_item (+45 nodes collapsed)
impl_item (+127 nodes collapsed)
impl_item
impl "impl"
type_identifier "ScrollableHandle"
for "for"
type_identifier "TerminalScrollHandle"
declaration_list
{ "{"
function_item
fn "fn"
identifier "max_offset"
parameters
( "("
self_parameter
& "&"
self "self"
) ")"
-> "->"
generic_type
type_identifier "Point"
type_arguments
< "<"
type_identifier "Pixels"
> ">"
block
{ "{"
let_declaration
let "let"
identifier "state"
= "="
call_expression
field_expression
field_expression
self "self"
. "."
field_identifier "state"
. "."
field_identifier "borrow"
arguments
( "("
) ")"
; ";"
call_expression
identifier "point"
arguments (+33 nodes collapsed)
} "}"
function_item (+94 nodes collapsed)
function_item (+136 nodes collapsed)
function_item (+90 nodes collapsed)
} "}"