Comparison

util/human/io.lua @ 13067:386ca97bec5b

util.human.io: Fix error with ellipsis to negative length Can happen if you resize the terminal too narrow that the space left for variable width columns end up negative.
author Kim Alvefur <zash@zash.se>
date Sun, 09 Apr 2023 01:34:08 +0200
parent 13054:f4d7fe919969
child 13068:7a75cbc4d87c
comparison
equal deleted inserted replaced
13066:4aa4a51a7a77 13067:386ca97bec5b
121 return tonumber(result or default); 121 return tonumber(result or default);
122 end 122 end
123 123
124 local function ellipsis(s, width) 124 local function ellipsis(s, width)
125 if len(s) <= width then return s; end 125 if len(s) <= width then return s; end
126 if width == 1 then return "…"; end 126 if width <= 1 then return "…"; end
127 return utf8_cut(s, width - 1) .. "…"; 127 return utf8_cut(s, width - 1) .. "…";
128 end 128 end
129 129
130 local function new_table(col_specs, max_width) 130 local function new_table(col_specs, max_width)
131 max_width = max_width or term_width(80); 131 max_width = max_width or term_width(80);