@@ -36,7 +36,7 @@ contains |
| 36 | logical, dimension(*), intent(in) :: is_selected | 36 | logical, dimension(*), intent(in) :: is_selected |
| 37 | integer, intent(in) :: selection_count | 37 | integer, intent(in) :: selection_count |
| 38 | logical, dimension(*), intent(in) :: current_is_favorite, parent_is_favorite | 38 | logical, dimension(*), intent(in) :: current_is_favorite, parent_is_favorite |
| 39 | - integer :: left_w, i, parent_idx, current_idx, vis_h | 39 | + integer :: left_w, i, parent_idx, current_idx, vis_h, display_len |
| 40 | character(len=256) :: fname | 40 | character(len=256) :: fname |
| 41 | character(len=20) :: color_code | 41 | character(len=20) :: color_code |
| 42 | | 42 | |
@@ -84,9 +84,11 @@ contains |
| 84 | if (parent_idx >= 1 .and. parent_idx <= parent_count) then | 84 | if (parent_idx >= 1 .and. parent_idx <= parent_count) then |
| 85 | fname = parent_files(parent_idx) | 85 | fname = parent_files(parent_idx) |
| 86 | | 86 | |
| 87 | - ! Add star for favorited directories | 87 | + ! Track if this item has a star (for visual width adjustment) |
| | 88 | + display_len = 0 |
| 88 | if (parent_is_favorite(parent_idx)) then | 89 | if (parent_is_favorite(parent_idx)) then |
| 89 | fname = "★ " // trim(fname) | 90 | fname = "★ " // trim(fname) |
| | 91 | + display_len = 1 ! Star takes 2 visual columns, so add 1 extra |
| 90 | end if | 92 | end if |
| 91 | | 93 | |
| 92 | if (parent_is_dir(parent_idx) .and. parent_files(parent_idx) /= "." .and. parent_files(parent_idx) /= "..") then | 94 | if (parent_is_dir(parent_idx) .and. parent_files(parent_idx) /= "." .and. parent_files(parent_idx) /= "..") then |
@@ -96,14 +98,17 @@ contains |
| 96 | ! Get color for parent file | 98 | ! Get color for parent file |
| 97 | color_code = get_file_color(parent_files(parent_idx), parent_is_dir(parent_idx), parent_is_exec(parent_idx)) | 99 | color_code = get_file_color(parent_files(parent_idx), parent_is_dir(parent_idx), parent_is_exec(parent_idx)) |
| 98 | | 100 | |
| | 101 | + ! Calculate visual width: string length + extra for wide char |
| | 102 | + display_len = min(len_trim(fname) + display_len, left_w) |
| | 103 | + |
| 99 | if (parent_idx == parent_selected) then | 104 | if (parent_idx == parent_selected) then |
| 100 | write(output_unit, '(a)', advance='no') DIM // BOLD // trim(color_code) // & | 105 | write(output_unit, '(a)', advance='no') DIM // BOLD // trim(color_code) // & |
| 101 | - fname(1:min(len_trim(fname),left_w)) // RESET | 106 | + fname(1:min(len_trim(fname), left_w)) // RESET |
| 102 | else | 107 | else |
| 103 | write(output_unit, '(a)', advance='no') DIM // trim(color_code) // & | 108 | write(output_unit, '(a)', advance='no') DIM // trim(color_code) // & |
| 104 | - fname(1:min(len_trim(fname),left_w)) // RESET | 109 | + fname(1:min(len_trim(fname), left_w)) // RESET |
| 105 | end if | 110 | end if |
| 106 | - write(output_unit, '(a)', advance='no') repeat(" ", max(0, left_w - len_trim(fname))) | 111 | + write(output_unit, '(a)', advance='no') repeat(" ", max(0, left_w - display_len)) |
| 107 | else | 112 | else |
| 108 | write(output_unit, '(a)', advance='no') repeat(" ", left_w) | 113 | write(output_unit, '(a)', advance='no') repeat(" ", left_w) |
| 109 | end if | 114 | end if |
@@ -115,15 +120,20 @@ contains |
| 115 | if (current_idx >= 1 .and. current_idx <= current_count) then | 120 | if (current_idx >= 1 .and. current_idx <= current_count) then |
| 116 | fname = current_files(current_idx) | 121 | fname = current_files(current_idx) |
| 117 | | 122 | |
| 118 | - ! Add star for favorited directories | 123 | + ! Track if this item has a star (for visual width - star takes 2 columns) |
| | 124 | + display_len = 0 |
| 119 | if (current_is_favorite(current_idx)) then | 125 | if (current_is_favorite(current_idx)) then |
| 120 | fname = "★ " // trim(fname) | 126 | fname = "★ " // trim(fname) |
| | 127 | + display_len = 1 ! Add 1 to account for star being 2 visual columns |
| 121 | end if | 128 | end if |
| 122 | | 129 | |
| 123 | if (current_is_dir(current_idx) .and. current_files(current_idx) /= "." .and. current_files(current_idx) /= "..") then | 130 | if (current_is_dir(current_idx) .and. current_files(current_idx) /= "." .and. current_files(current_idx) /= "..") then |
| 124 | fname = trim(fname) // "/" | 131 | fname = trim(fname) // "/" |
| 125 | end if | 132 | end if |
| 126 | | 133 | |
| | 134 | + ! Store the visual display length for this line (used by git indicators) |
| | 135 | + display_len = len_trim(fname) + display_len |
| | 136 | + |
| 127 | ! Get color for current file | 137 | ! Get color for current file |
| 128 | color_code = get_file_color(current_files(current_idx), current_is_dir(current_idx), current_is_exec(current_idx)) | 138 | color_code = get_file_color(current_files(current_idx), current_is_dir(current_idx), current_is_exec(current_idx)) |
| 129 | | 139 | |