From: William Morgan Date: Sun, 3 Feb 2008 00:04:53 +0000 (-0800) Subject: fix ThreadViewMode#jump_to_next_open to deal with left alignment correctly X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=1b2ca5485ea8e41bd8b4d641fa8f0d1bdba784c6;p=sup fix ThreadViewMode#jump_to_next_open to deal with left alignment correctly --- diff --git a/lib/sup/modes/thread-view-mode.rb b/lib/sup/modes/thread-view-mode.rb index 961fc5d..fb324c1 100644 --- a/lib/sup/modes/thread-view-mode.rb +++ b/lib/sup/modes/thread-view-mode.rb @@ -318,6 +318,8 @@ EOS end end + IDEAL_TOP_CONTEXT = 3 # try and give 3 rows of top context + IDEAL_LEFT_CONTEXT = 4 # try and give 4 columns of left context def jump_to_message m, loose_alignment=false l = @layout[m] left = l.depth * INDENT_SPACES @@ -325,19 +327,20 @@ EOS ## jump to the top line if loose_alignment - jump_to_line [l.top - 3, 0].max # give 3 lines of top context + jump_to_line [l.top - IDEAL_TOP_CONTEXT, 0].max # give 3 lines of top context else jump_to_line l.top end ## jump to the left column - if loose_alignment - ## try and give 4 columns of left context, but not if it means that - ## the right of the message is truncated. - jump_to_col [[left - 4, rightcol - l.width - 1].min, 0].max - else - jump_to_col left - end + ideal_left = left + + if loose_alignment + -IDEAL_LEFT_CONTEXT + (l.width - buffer.content_width + IDEAL_LEFT_CONTEXT + 1).clamp(0, IDEAL_LEFT_CONTEXT) + else + 0 + end + + jump_to_col [ideal_left, 0].max ## either way, move the cursor to the first line set_cursor_pos l.top