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

1//! Renders a div with deep children hierarchy. This example is useful to exemplify that Zed can
2//! handle deep hierarchies (even though it cannot just yet!).
3use std::sync::LazyLock;
4
5use gpui::{App, Bounds, Context, Window, WindowBounds, WindowOptions, div, prelude::*, px, size};
6use gpui_platform::application;
7
…lines 8–24 unchanged (17 lines)
25 innermost_node = next_div().child(innermost_node);
26 depth -= 1;
27 }
28 innermost_node
29 }
30}
31
32fn main() {
33 application().run(|cx: &mut App| {
34 let bounds = Bounds::centered(None, size(px(300.0), px(300.0)), cx);
35 cx.open_window(
36 WindowOptions {
37 window_bounds: Some(WindowBounds::Windowed(bounds)),
38 ..Default::default()
39 },
40 |_, cx| cx.new(|_| Tree {}),
41 )
42 .unwrap();
43 });
44}
45

After

1#![cfg_attr(target_family = "wasm", no_main)]
2//! Renders a div with deep children hierarchy. This example is useful to exemplify that Zed can
3//! handle deep hierarchies (even though it cannot just yet!).
4use std::sync::LazyLock;
5
6use gpui::{App, Bounds, Context, Window, WindowBounds, WindowOptions, div, prelude::*, px, size};
7use gpui_platform::application;
…lines 8–26 unchanged (19 lines)
27 depth -= 1;
28 }
29 innermost_node
30 }
31}
32
33fn run_example() {
34 application().run(|cx: &mut App| {
35 let bounds = Bounds::centered(None, size(px(300.0), px(300.0)), cx);
36 cx.open_window(
37 WindowOptions {
38 window_bounds: Some(WindowBounds::Windowed(bounds)),
39 ..Default::default()
40 },
41 |_, cx| cx.new(|_| Tree {}),
42 )
43 .unwrap();
44 });
45}
46
47#[cfg(not(target_family = "wasm"))]
48fn main() {
49 run_example();
50}
51
52#[cfg(target_family = "wasm")]
53#[wasm_bindgen::prelude::wasm_bindgen(start)]
54pub fn start() {
55 gpui_platform::web_init();
56 run_example();
57}
58

Before

source_file
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Renders a div with deep children hierarchy. This example is"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " handle deep hierarchies (even though it cannot just yet!).\n"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "sync"
:: "::"
identifier "LazyLock"
; ";"
use_declaration (+31 nodes collapsed)
use_declaration
use "use"
scoped_identifier
identifier "gpui_platform"
:: "::"
identifier "application"
; ";"
struct_item
struct "struct"
type_identifier "Tree"
field_declaration_list
{ "{"
} "}"
static_item (+88 nodes collapsed)
impl_item (+226 nodes collapsed)
function_item
fn "fn"
identifier "main"
parameters
( "("
) ")"
block
{ "{"
expression_statement (+140 nodes collapsed)
} "}"

After

source_file
inner_attribute_item
# "#"
! "!"
[ "["
attribute
identifier "cfg_attr"
token_tree
( "("
identifier "target_family"
= "="
string_literal
" "\""
string_content "wasm"
" "\""
, ","
identifier "no_main"
) ")"
] "]"
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " Renders a div with deep children hierarchy. This example is"...
line_comment
// "//"
inner_doc_comment_marker
! "!"
doc_comment " handle deep hierarchies (even though it cannot just yet!).\n"
use_declaration
use "use"
scoped_identifier
scoped_identifier
identifier "std"
:: "::"
identifier "sync"
:: "::"
identifier "LazyLock"
; ";"
use_declaration (+31 nodes collapsed)
use_declaration
use "use"
scoped_identifier
identifier "gpui_platform"
:: "::"
identifier "application"
; ";"
struct_item
struct "struct"
type_identifier "Tree"
field_declaration_list
{ "{"
} "}"
static_item (+88 nodes collapsed)
impl_item (+226 nodes collapsed)
function_item
fn "fn"
identifier "run_example"
parameters
( "("
) ")"
block
{ "{"
expression_statement (+140 nodes collapsed)
} "}"
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "not"
token_tree
( "("
identifier "target_family"
= "="
string_literal
" "\""
string_content "wasm"
" "\""
) ")"
) ")"
] "]"
function_item
fn "fn"
identifier "main"
parameters
( "("
) ")"
block
{ "{"
expression_statement
call_expression
identifier "run_example"
arguments
( "("
) ")"
; ";"
} "}"
attribute_item
# "#"
[ "["
attribute
identifier "cfg"
token_tree
( "("
identifier "target_family"
= "="
string_literal
" "\""
string_content "wasm"
" "\""
) ")"
] "]"
attribute_item
# "#"
[ "["
attribute
scoped_identifier
scoped_identifier
identifier "wasm_bindgen"
:: "::"
identifier "prelude"
:: "::"
identifier "wasm_bindgen"
token_tree
( "("
identifier "start"
) ")"
] "]"
function_item
visibility_modifier
pub "pub"
fn "fn"
identifier "start"
parameters
( "("
) ")"
block
{ "{"
expression_statement
call_expression
scoped_identifier
identifier "gpui_platform"
:: "::"
identifier "web_init"
arguments
( "("
) ")"
; ";"
expression_statement
call_expression
identifier "run_example"
arguments
( "("
) ")"
; ";"
} "}"