@@ -860,6 +860,7 @@ fn align_selections(cx: &mut Context) {
860
860
861
861
let transaction = Transaction :: change ( doc. text ( ) , changes. into_iter ( ) ) ;
862
862
doc. apply ( & transaction, view. id ) ;
863
+ view. apply ( & transaction, doc) ;
863
864
}
864
865
865
866
fn goto_window ( cx : & mut Context , align : Align ) {
@@ -1290,6 +1291,7 @@ fn replace(cx: &mut Context) {
1290
1291
} ) ;
1291
1292
1292
1293
doc. apply ( & transaction, view. id ) ;
1294
+ view. apply ( & transaction, doc) ;
1293
1295
}
1294
1296
} )
1295
1297
}
@@ -1307,6 +1309,7 @@ where
1307
1309
} ) ;
1308
1310
1309
1311
doc. apply ( & transaction, view. id ) ;
1312
+ view. apply ( & transaction, doc) ;
1310
1313
}
1311
1314
1312
1315
fn switch_case ( cx : & mut Context ) {
@@ -2113,6 +2116,7 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) {
2113
2116
( range. from ( ) , range. to ( ) , None )
2114
2117
} ) ;
2115
2118
doc. apply ( & transaction, view. id ) ;
2119
+ view. apply ( & transaction, doc) ;
2116
2120
2117
2121
match op {
2118
2122
Operation :: Delete => {
@@ -2126,14 +2130,15 @@ fn delete_selection_impl(cx: &mut Context, op: Operation) {
2126
2130
}
2127
2131
2128
2132
#[ inline]
2129
- fn delete_selection_insert_mode ( doc : & mut Document , view : & View , selection : & Selection ) {
2133
+ fn delete_selection_insert_mode ( doc : & mut Document , view : & mut View , selection : & Selection ) {
2130
2134
let view_id = view. id ;
2131
2135
2132
2136
// then delete
2133
2137
let transaction = Transaction :: change_by_selection ( doc. text ( ) , selection, |range| {
2134
2138
( range. from ( ) , range. to ( ) , None )
2135
2139
} ) ;
2136
2140
doc. apply ( & transaction, view_id) ;
2141
+ view. apply ( & transaction, doc) ;
2137
2142
}
2138
2143
2139
2144
fn delete_selection ( cx : & mut Context ) {
@@ -2230,6 +2235,7 @@ fn append_mode(cx: &mut Context) {
2230
2235
[ ( end, end, Some ( doc. line_ending . as_str ( ) . into ( ) ) ) ] . into_iter ( ) ,
2231
2236
) ;
2232
2237
doc. apply ( & transaction, view. id ) ;
2238
+ view. apply ( & transaction, doc) ;
2233
2239
}
2234
2240
2235
2241
let selection = doc. selection ( view. id ) . clone ( ) . transform ( |range| {
@@ -2530,6 +2536,7 @@ async fn make_format_callback(
2530
2536
let view = view_mut ! ( editor) ;
2531
2537
if doc. version ( ) == doc_version {
2532
2538
doc. apply ( & format, view. id ) ;
2539
+ view. apply ( & format, doc) ;
2533
2540
doc. append_changes_to_history ( view. id ) ;
2534
2541
doc. detect_indent_and_line_ending ( ) ;
2535
2542
view. ensure_cursor_in_view ( doc, scrolloff) ;
@@ -2617,6 +2624,7 @@ fn open(cx: &mut Context, open: Open) {
2617
2624
transaction = transaction. with_selection ( Selection :: new ( ranges, selection. primary_index ( ) ) ) ;
2618
2625
2619
2626
doc. apply ( & transaction, view. id ) ;
2627
+ view. apply ( & transaction, doc) ;
2620
2628
}
2621
2629
2622
2630
// o inserts a new line after each line with a selection
@@ -2637,7 +2645,7 @@ fn normal_mode(cx: &mut Context) {
2637
2645
cx. editor . mode = Mode :: Normal ;
2638
2646
let ( view, doc) = current ! ( cx. editor) ;
2639
2647
2640
- try_restore_indent ( doc, view. id ) ;
2648
+ try_restore_indent ( doc, view) ;
2641
2649
2642
2650
// if leaving append mode, move cursor back by 1
2643
2651
if doc. restore_cursor {
@@ -2654,7 +2662,7 @@ fn normal_mode(cx: &mut Context) {
2654
2662
}
2655
2663
}
2656
2664
2657
- fn try_restore_indent ( doc : & mut Document , view_id : ViewId ) {
2665
+ fn try_restore_indent ( doc : & mut Document , view : & mut View ) {
2658
2666
use helix_core:: chars:: char_is_whitespace;
2659
2667
use helix_core:: Operation ;
2660
2668
@@ -2673,18 +2681,19 @@ fn try_restore_indent(doc: &mut Document, view_id: ViewId) {
2673
2681
2674
2682
let doc_changes = doc. changes ( ) . changes ( ) ;
2675
2683
let text = doc. text ( ) . slice ( ..) ;
2676
- let range = doc. selection ( view_id ) . primary ( ) ;
2684
+ let range = doc. selection ( view . id ) . primary ( ) ;
2677
2685
let pos = range. cursor ( text) ;
2678
2686
let line_end_pos = line_end_char_index ( & text, range. cursor_line ( text) ) ;
2679
2687
2680
2688
if inserted_a_new_blank_line ( doc_changes, pos, line_end_pos) {
2681
2689
// Removes tailing whitespaces.
2682
2690
let transaction =
2683
- Transaction :: change_by_selection ( doc. text ( ) , doc. selection ( view_id ) , |range| {
2691
+ Transaction :: change_by_selection ( doc. text ( ) , doc. selection ( view . id ) , |range| {
2684
2692
let line_start_pos = text. line_to_char ( range. cursor_line ( text) ) ;
2685
2693
( line_start_pos, pos, None )
2686
2694
} ) ;
2687
- doc. apply ( & transaction, view_id) ;
2695
+ doc. apply ( & transaction, view. id ) ;
2696
+ view. apply ( & transaction, doc) ;
2688
2697
}
2689
2698
}
2690
2699
@@ -2999,6 +3008,7 @@ pub mod insert {
2999
3008
let ( view, doc) = current ! ( cx. editor) ;
3000
3009
if let Some ( t) = transaction {
3001
3010
doc. apply ( & t, view. id ) ;
3011
+ view. apply ( & t, doc) ;
3002
3012
}
3003
3013
3004
3014
// TODO: need a post insert hook too for certain triggers (autocomplete, signature help, etc)
@@ -3021,6 +3031,7 @@ pub mod insert {
3021
3031
indent,
3022
3032
) ;
3023
3033
doc. apply ( & transaction, view. id ) ;
3034
+ view. apply ( & transaction, doc) ;
3024
3035
}
3025
3036
3026
3037
pub fn insert_newline ( cx : & mut Context ) {
@@ -3108,6 +3119,7 @@ pub mod insert {
3108
3119
3109
3120
let ( view, doc) = current ! ( cx. editor) ;
3110
3121
doc. apply ( & transaction, view. id ) ;
3122
+ view. apply ( & transaction, doc) ;
3111
3123
}
3112
3124
3113
3125
pub fn delete_char_backward ( cx : & mut Context ) {
@@ -3202,6 +3214,7 @@ pub mod insert {
3202
3214
} ) ;
3203
3215
let ( view, doc) = current ! ( cx. editor) ;
3204
3216
doc. apply ( & transaction, view. id ) ;
3217
+ view. apply ( & transaction, doc) ;
3205
3218
3206
3219
lsp:: signature_help_impl ( cx, SignatureHelpInvoked :: Automatic ) ;
3207
3220
}
@@ -3220,6 +3233,7 @@ pub mod insert {
3220
3233
)
3221
3234
} ) ;
3222
3235
doc. apply ( & transaction, view. id ) ;
3236
+ view. apply ( & transaction, doc) ;
3223
3237
3224
3238
lsp:: signature_help_impl ( cx, SignatureHelpInvoked :: Automatic ) ;
3225
3239
}
@@ -3413,7 +3427,7 @@ enum Paste {
3413
3427
Cursor ,
3414
3428
}
3415
3429
3416
- fn paste_impl ( values : & [ String ] , doc : & mut Document , view : & View , action : Paste , count : usize ) {
3430
+ fn paste_impl ( values : & [ String ] , doc : & mut Document , view : & mut View , action : Paste , count : usize ) {
3417
3431
let repeat = std:: iter:: repeat (
3418
3432
values
3419
3433
. last ( )
@@ -3457,6 +3471,7 @@ fn paste_impl(values: &[String], doc: &mut Document, view: &View, action: Paste,
3457
3471
( pos, pos, values. next ( ) )
3458
3472
} ) ;
3459
3473
doc. apply ( & transaction, view. id ) ;
3474
+ view. apply ( & transaction, doc) ;
3460
3475
}
3461
3476
3462
3477
pub ( crate ) fn paste_bracketed_value ( cx : & mut Context , contents : String ) {
@@ -3549,6 +3564,7 @@ fn replace_with_yanked(cx: &mut Context) {
3549
3564
} ) ;
3550
3565
3551
3566
doc. apply ( & transaction, view. id ) ;
3567
+ view. apply ( & transaction, doc) ;
3552
3568
}
3553
3569
}
3554
3570
}
@@ -3572,6 +3588,7 @@ fn replace_selections_with_clipboard_impl(
3572
3588
} ) ;
3573
3589
3574
3590
doc. apply ( & transaction, view. id ) ;
3591
+ view. apply ( & transaction, doc) ;
3575
3592
doc. append_changes_to_history ( view. id ) ;
3576
3593
Ok ( ( ) )
3577
3594
}
@@ -3642,6 +3659,7 @@ fn indent(cx: &mut Context) {
3642
3659
} ) ,
3643
3660
) ;
3644
3661
doc. apply ( & transaction, view. id ) ;
3662
+ view. apply ( & transaction, doc) ;
3645
3663
}
3646
3664
3647
3665
fn unindent ( cx : & mut Context ) {
@@ -3681,6 +3699,7 @@ fn unindent(cx: &mut Context) {
3681
3699
let transaction = Transaction :: change ( doc. text ( ) , changes. into_iter ( ) ) ;
3682
3700
3683
3701
doc. apply ( & transaction, view. id ) ;
3702
+ view. apply ( & transaction, doc) ;
3684
3703
}
3685
3704
3686
3705
fn format_selections ( cx : & mut Context ) {
@@ -3728,6 +3747,7 @@ fn format_selections(cx: &mut Context) {
3728
3747
// );
3729
3748
3730
3749
// doc.apply(&transaction, view.id);
3750
+ // view.apply(&transaction, doc);
3731
3751
}
3732
3752
}
3733
3753
@@ -3783,6 +3803,7 @@ fn join_selections_inner(cx: &mut Context, select_space: bool) {
3783
3803
} ;
3784
3804
3785
3805
doc. apply ( & transaction, view. id ) ;
3806
+ view. apply ( & transaction, doc) ;
3786
3807
}
3787
3808
3788
3809
fn keep_or_remove_selections_impl ( cx : & mut Context , remove : bool ) {
@@ -3936,6 +3957,7 @@ fn toggle_comments(cx: &mut Context) {
3936
3957
let transaction = comment:: toggle_line_comments ( doc. text ( ) , doc. selection ( view. id ) , token) ;
3937
3958
3938
3959
doc. apply ( & transaction, view. id ) ;
3960
+ view. apply ( & transaction, doc) ;
3939
3961
exit_select_mode ( cx) ;
3940
3962
}
3941
3963
@@ -3992,6 +4014,7 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
3992
4014
) ;
3993
4015
3994
4016
doc. apply ( & transaction, view. id ) ;
4017
+ view. apply ( & transaction, doc) ;
3995
4018
}
3996
4019
3997
4020
fn rotate_selection_contents_forward ( cx : & mut Context ) {
@@ -4488,6 +4511,7 @@ fn surround_add(cx: &mut Context) {
4488
4511
4489
4512
let transaction = Transaction :: change ( doc. text ( ) , changes. into_iter ( ) ) ;
4490
4513
doc. apply ( & transaction, view. id ) ;
4514
+ view. apply ( & transaction, doc) ;
4491
4515
} )
4492
4516
}
4493
4517
@@ -4527,6 +4551,7 @@ fn surround_replace(cx: &mut Context) {
4527
4551
} ) ,
4528
4552
) ;
4529
4553
doc. apply ( & transaction, view. id ) ;
4554
+ view. apply ( & transaction, doc) ;
4530
4555
} ) ;
4531
4556
} )
4532
4557
}
@@ -4554,6 +4579,7 @@ fn surround_delete(cx: &mut Context) {
4554
4579
let transaction =
4555
4580
Transaction :: change ( doc. text ( ) , change_pos. into_iter ( ) . map ( |p| ( p, p + 1 , None ) ) ) ;
4556
4581
doc. apply ( & transaction, view. id ) ;
4582
+ view. apply ( & transaction, doc) ;
4557
4583
} )
4558
4584
}
4559
4585
@@ -4729,6 +4755,7 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
4729
4755
if behavior != & ShellBehavior :: Ignore {
4730
4756
let transaction = Transaction :: change ( doc. text ( ) , changes. into_iter ( ) ) ;
4731
4757
doc. apply ( & transaction, view. id ) ;
4758
+ view. apply ( & transaction, doc) ;
4732
4759
doc. append_changes_to_history ( view. id ) ;
4733
4760
}
4734
4761
@@ -4792,6 +4819,7 @@ fn add_newline_impl(cx: &mut Context, open: Open) {
4792
4819
4793
4820
let transaction = Transaction :: change ( text, changes) ;
4794
4821
doc. apply ( & transaction, view. id ) ;
4822
+ view. apply ( & transaction, doc) ;
4795
4823
}
4796
4824
4797
4825
/// Increment object under cursor by count.
@@ -4885,6 +4913,7 @@ fn increment_impl(cx: &mut Context, amount: i64) {
4885
4913
let transaction = transaction. with_selection ( selection. clone ( ) ) ;
4886
4914
4887
4915
doc. apply ( & transaction, view. id ) ;
4916
+ view. apply ( & transaction, doc) ;
4888
4917
}
4889
4918
}
4890
4919
0 commit comments