@@ -215,7 +215,6 @@ object(self)
215215 val mutable local_bindings = Bindings. empty
216216 method bind keys actions = local_bindings < - Bindings. add keys actions local_bindings
217217
218- val mutable shift = 0
219218 val mutable shift_width = 0
220219 val mutable start = 0
221220 val mutable start_line = 0
@@ -228,45 +227,16 @@ object(self)
228227 let line_count = Zed_lines. count line_set in
229228 let cursor_offset = Zed_cursor. get_position cursor in
230229 let cursor_line = Zed_lines. line_index line_set cursor_offset in
231- let line_start= Zed_lines. line_start line_set cursor_line in
232230 let cursor_column = cursor_offset - Zed_lines. line_start line_set cursor_line in
233231 let column_display= Zed_lines. force_width line_set (Zed_lines. line_start line_set cursor_line) cursor_column in
234232
235- let calc_delta width_delta =
236- let rec forward idx acc =
237- if acc < width_delta then
238- forward (idx + 1 ) (acc + Zed_lines. force_width line_set idx 1 )
239- else
240- idx
241- in
242- let rec backward idx acc =
243- if acc > width_delta then
244- backward (idx - 1 ) (acc - Zed_lines. force_width line_set (idx - 1 ) 1 )
245- else
246- idx
247- in
248- if width_delta > 0 then
249- forward (line_start + shift) 0 - (line_start + shift)
250- else if width_delta < 0 then
251- backward cursor_offset 0 - cursor_offset
252- else 0
253- in
254233
255234 (* ** check cursor position is in view *)
256235
257236 (* Horizontal check *)
258237 if column_display < shift_width || column_display > = shift_width + size.cols then begin
259238
260- let shift_new= max 0 (column_display - size.cols / 2 ) in
261- if shift_new = 0 then
262- shift < - 0
263- else
264- begin
265- let width_delta= shift_new - shift_width in
266- let shift_delta= calc_delta width_delta in
267- shift < - shift + shift_delta;
268- end ;
269- shift_width < - Zed_lines. force_width line_set line_start shift;
239+ shift_width < - max 0 (column_display - size.cols / 2 );
270240 end ;
271241
272242 (* Vertical check *)
@@ -373,7 +343,7 @@ object(self)
373343 size < - size_of_rect rect;
374344 super#set_allocation rect;
375345 vscroll#set_page_size size.rows;
376- start < - 0 ; shift < - 0 ; shift_width < - 0 ; start_line < - 0 ;
346+ start < - 0 ; shift_width < - 0 ; start_line < - 0 ;
377347 self#update_window_position
378348
379349 initializer vscroll#on_offset_change (fun n ->
@@ -446,8 +416,8 @@ object(self)
446416 skip_eol row zip
447417
448418 and skip_bol row zip remaining =
449- if remaining = 0 then
450- draw_line row 0 zip
419+ if remaining < = 0 then
420+ draw_line row ( - remaining) zip
451421 else if Zed_rope.Zip. at_eos zip then
452422 draw_eoi (row + 1 )
453423 else
@@ -456,13 +426,13 @@ object(self)
456426 let row = row + 1 in
457427 if row < size.rows then begin_line row zip
458428 end else
459- skip_bol row zip (remaining - 1 )
429+ skip_bol row zip (remaining - ( Zed_char. width char ) )
460430
461431 and begin_line row zip =
462432 if Zed_rope.Zip. at_eos zip then
463433 draw_eoi row
464- else if shift <> 0 then begin
465- skip_bol row zip shift
434+ else if shift_width <> 0 then begin
435+ skip_bol row zip shift_width
466436 end else
467437 draw_line row 0 zip
468438
0 commit comments