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

…lines 1–63 unchanged (63 lines)
64 rangeStartLineIdx := 0
65 if oldState != nil {
66 rangeStartLineIdx = oldState.rangeStartLineIdx
67 }
68
69 selectMode := LINE
70 if useHunkModeByDefault {
71 selectMode = HUNK
72 }
73
74 userEnabledHunkMode := false
75 if oldState != nil {
76 userEnabledHunkMode = oldState.userEnabledHunkMode
…lines 77–422 unchanged (346 lines)

After

…lines 1–63 unchanged (63 lines)
64 rangeStartLineIdx := 0
65 if oldState != nil {
66 rangeStartLineIdx = oldState.rangeStartLineIdx
67 }
68
69 selectMode := LINE
70 if useHunkModeByDefault && !patch.IsSingleHunkForWholeFile() {
71 selectMode = HUNK
72 }
73
74 userEnabledHunkMode := false
75 if oldState != nil {
76 userEnabledHunkMode = oldState.userEnabledHunkMode
…lines 77–422 unchanged (346 lines)

Before

source_file
package_clause
package "package"
package_identifier "patch_exploring"
import_declaration (+35 nodes collapsed)
comment "// State represents the current state of the patch explorer "...
comment "// you're staging a file or you're building a patch from an "...
comment "// this struct holds the info about the diff you're interact"...
type_declaration (+56 nodes collapsed)
comment "// these represent what select mode we're in"
type_declaration
type "type"
type_spec
type_identifier "selectMode"
type_identifier "int"
const_declaration
const "const"
( "("
const_spec
identifier "LINE"
type_identifier "selectMode"
= "="
expression_list
iota "iota"
const_spec
identifier "RANGE"
const_spec
identifier "HUNK"
) ")"
function_declaration
func "func"
identifier "NewState"
parameter_list (+29 nodes collapsed)
pointer_type
* "*"
type_identifier "State"
block
{ "{"
statement_list
if_statement (+34 nodes collapsed)
short_var_declaration
expression_list
identifier "patch"
:= ":="
expression_list
call_expression
selector_expression
identifier "patch"
. "."
field_identifier "Parse"
argument_list
( "("
identifier "diff"
) ")"
if_statement
if "if"
unary_expression
! "!"
call_expression
selector_expression
identifier "patch"
. "."
field_identifier "ContainsChanges"
argument_list
( "("
) ")"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
} "}"
short_var_declaration
expression_list
identifier "viewLineIndices"
, ","
identifier "patchLineIndices"
:= ":="
expression_list
call_expression
identifier "wrapPatchLines"
argument_list
( "("
identifier "diff"
, ","
identifier "view"
) ")"
short_var_declaration
expression_list
identifier "rangeStartLineIdx"
:= ":="
expression_list
int_literal "0"
if_statement
if "if"
binary_expression
identifier "oldState"
!= "!="
nil "nil"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "rangeStartLineIdx"
= "="
expression_list
selector_expression
identifier "oldState"
. "."
field_identifier "rangeStartLineIdx"
} "}"
short_var_declaration
expression_list
identifier "selectMode"
:= ":="
expression_list
identifier "LINE"
if_statement
if "if"
identifier "useHunkModeByDefault"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "selectMode"
= "="
expression_list
identifier "HUNK"
} "}"
short_var_declaration
expression_list
identifier "userEnabledHunkMode"
:= ":="
expression_list
false "false"
if_statement
if "if"
binary_expression
identifier "oldState"
!= "!="
nil "nil"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "userEnabledHunkMode"
= "="
expression_list
selector_expression
identifier "oldState"
. "."
field_identifier "userEnabledHunkMode"
} "}"
comment "// if we have clicked from the outside to focus the main vie"...
if_statement (+130 nodes collapsed)
return_statement (+73 nodes collapsed)
} "}"
method_declaration (+159 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+102 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+79 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+29 nodes collapsed)
method_declaration (+35 nodes collapsed)
method_declaration (+50 nodes collapsed)
method_declaration (+29 nodes collapsed)
method_declaration (+27 nodes collapsed)
method_declaration (+41 nodes collapsed)
comment "// For when you move the cursor without holding shift (meani"...
comment "// a non-sticky range select, we'll cancel it)"
method_declaration (+61 nodes collapsed)
method_declaration (+49 nodes collapsed)
comment "// This just moves the cursor without caring about range sel"...
method_declaration (+38 nodes collapsed)
method_declaration (+57 nodes collapsed)
method_declaration (+40 nodes collapsed)
method_declaration (+80 nodes collapsed)
method_declaration (+175 nodes collapsed)
method_declaration (+159 nodes collapsed)
method_declaration (+60 nodes collapsed)
comment "// This is called when we use shift+arrow to expand the rang"...
comment "// range)"
method_declaration (+96 nodes collapsed)
comment "// returns first and last patch line index of current hunk"
method_declaration (+93 nodes collapsed)
method_declaration (+216 nodes collapsed)
method_declaration (+126 nodes collapsed)
method_declaration (+61 nodes collapsed)
comment "// Returns the line indices of the selected patch range that"...
method_declaration (+147 nodes collapsed)
method_declaration (+44 nodes collapsed)
method_declaration (+46 nodes collapsed)
method_declaration (+68 nodes collapsed)
method_declaration (+51 nodes collapsed)
method_declaration (+48 nodes collapsed)
method_declaration (+37 nodes collapsed)
method_declaration (+76 nodes collapsed)
function_declaration (+97 nodes collapsed)
method_declaration (+93 nodes collapsed)

After

source_file
package_clause
package "package"
package_identifier "patch_exploring"
import_declaration (+35 nodes collapsed)
comment "// State represents the current state of the patch explorer "...
comment "// you're staging a file or you're building a patch from an "...
comment "// this struct holds the info about the diff you're interact"...
type_declaration (+56 nodes collapsed)
comment "// these represent what select mode we're in"
type_declaration
type "type"
type_spec
type_identifier "selectMode"
type_identifier "int"
const_declaration
const "const"
( "("
const_spec
identifier "LINE"
type_identifier "selectMode"
= "="
expression_list
iota "iota"
const_spec
identifier "RANGE"
const_spec
identifier "HUNK"
) ")"
function_declaration
func "func"
identifier "NewState"
parameter_list (+29 nodes collapsed)
pointer_type
* "*"
type_identifier "State"
block
{ "{"
statement_list
if_statement (+34 nodes collapsed)
short_var_declaration
expression_list
identifier "patch"
:= ":="
expression_list
call_expression
selector_expression
identifier "patch"
. "."
field_identifier "Parse"
argument_list
( "("
identifier "diff"
) ")"
if_statement
if "if"
unary_expression
! "!"
call_expression
selector_expression
identifier "patch"
. "."
field_identifier "ContainsChanges"
argument_list
( "("
) ")"
block
{ "{"
statement_list
return_statement
return "return"
expression_list
nil "nil"
} "}"
short_var_declaration
expression_list
identifier "viewLineIndices"
, ","
identifier "patchLineIndices"
:= ":="
expression_list
call_expression
identifier "wrapPatchLines"
argument_list
( "("
identifier "diff"
, ","
identifier "view"
) ")"
short_var_declaration
expression_list
identifier "rangeStartLineIdx"
:= ":="
expression_list
int_literal "0"
if_statement
if "if"
binary_expression
identifier "oldState"
!= "!="
nil "nil"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "rangeStartLineIdx"
= "="
expression_list
selector_expression
identifier "oldState"
. "."
field_identifier "rangeStartLineIdx"
} "}"
short_var_declaration
expression_list
identifier "selectMode"
:= ":="
expression_list
identifier "LINE"
if_statement
if "if"
binary_expression
identifier "useHunkModeByDefault"
&& "&&"
unary_expression
! "!"
call_expression
selector_expression
identifier "patch"
. "."
field_identifier "IsSingleHunkForWholeFile"
argument_list
( "("
) ")"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "selectMode"
= "="
expression_list
identifier "HUNK"
} "}"
short_var_declaration
expression_list
identifier "userEnabledHunkMode"
:= ":="
expression_list
false "false"
if_statement
if "if"
binary_expression
identifier "oldState"
!= "!="
nil "nil"
block
{ "{"
statement_list
assignment_statement
expression_list
identifier "userEnabledHunkMode"
= "="
expression_list
selector_expression
identifier "oldState"
. "."
field_identifier "userEnabledHunkMode"
} "}"
comment "// if we have clicked from the outside to focus the main vie"...
if_statement (+130 nodes collapsed)
return_statement (+73 nodes collapsed)
} "}"
method_declaration (+159 nodes collapsed)
method_declaration (+33 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+26 nodes collapsed)
method_declaration (+102 nodes collapsed)
method_declaration (+28 nodes collapsed)
method_declaration (+79 nodes collapsed)
method_declaration (+30 nodes collapsed)
method_declaration (+29 nodes collapsed)
method_declaration (+35 nodes collapsed)
method_declaration (+50 nodes collapsed)
method_declaration (+29 nodes collapsed)
method_declaration (+27 nodes collapsed)
method_declaration (+41 nodes collapsed)
comment "// For when you move the cursor without holding shift (meani"...
comment "// a non-sticky range select, we'll cancel it)"
method_declaration (+61 nodes collapsed)
method_declaration (+49 nodes collapsed)
comment "// This just moves the cursor without caring about range sel"...
method_declaration (+38 nodes collapsed)
method_declaration (+57 nodes collapsed)
method_declaration (+40 nodes collapsed)
method_declaration (+80 nodes collapsed)
method_declaration (+175 nodes collapsed)
method_declaration (+159 nodes collapsed)
method_declaration (+60 nodes collapsed)
comment "// This is called when we use shift+arrow to expand the rang"...
comment "// range)"
method_declaration (+96 nodes collapsed)
comment "// returns first and last patch line index of current hunk"
method_declaration (+93 nodes collapsed)
method_declaration (+216 nodes collapsed)
method_declaration (+126 nodes collapsed)
method_declaration (+61 nodes collapsed)
comment "// Returns the line indices of the selected patch range that"...
method_declaration (+147 nodes collapsed)
method_declaration (+44 nodes collapsed)
method_declaration (+46 nodes collapsed)
method_declaration (+68 nodes collapsed)
method_declaration (+51 nodes collapsed)
method_declaration (+48 nodes collapsed)
method_declaration (+37 nodes collapsed)
method_declaration (+76 nodes collapsed)
function_declaration (+97 nodes collapsed)
method_declaration (+93 nodes collapsed)