File tree 1 file changed +8
-1
lines changed
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -185,15 +185,21 @@ def __init__(
185
185
self .wrapped = False
186
186
self ._start_x = file .buf .x + offset
187
187
self ._start_y = file .buf .y
188
+ self .original_line_change_diff = 0
188
189
189
190
def __iter__ (self ) -> _SearchIter :
190
191
return self
191
192
193
+ def calc_past_original_offset (self , y : int , match : Match [str ], replacement : str ):
194
+ if not self .wrapped or y != self ._start_y :
195
+ return
196
+ self .original_line_change_diff += len (replacement ) - (match .end ()- match .start ())
197
+
192
198
def _stop_if_past_original (self , y : int , match : Match [str ]) -> Found :
193
199
if (
194
200
self .wrapped and (
195
201
y > self ._start_y or
196
- y == self ._start_y and match .start () >= self ._start_x
202
+ y == self ._start_y and match .start () >= self ._start_x + self . original_line_change_diff
197
203
)
198
204
):
199
205
raise StopIteration ()
@@ -487,6 +493,7 @@ def replace(
487
493
count += 1
488
494
with self .edit_action_context ('replace' , final = True ):
489
495
replaced = match .expand (replace )
496
+ search .calc_past_original_offset (line_y , match , replaced )
490
497
line = screen .file .buf [line_y ]
491
498
if '\n ' in replaced :
492
499
replaced_lines = replaced .split ('\n ' )
You can’t perform that action at this time.
0 commit comments