From 17786fb0c6982888534885792b390d5ff9f9a342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Wed, 1 Mar 2017 18:04:15 +0100 Subject: vis-lua: make cursor.pos return nil if cursor position is invalid It remains to be seen whether that is a good idea, but at least it will reveal possible bugs. --- lua/vis-std.lua | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lua/vis-std.lua') diff --git a/lua/vis-std.lua b/lua/vis-std.lua index 5da6020..6499f24 100644 --- a/lua/vis-std.lua +++ b/lua/vis-std.lua @@ -108,7 +108,9 @@ vis.events.subscribe(vis.events.WIN_STATUS, function(win) end local size = file.size - table.insert(right_parts, (size == 0 and "0" or math.ceil(cursor.pos/size*100)).."%") + local pos = cursor.pos + if not pos then pos = 0 end + table.insert(right_parts, (size == 0 and "0" or math.ceil(pos/size*100)).."%") if not win.large then local col = cursor.col -- cgit v1.2.3