aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-03-01 18:04:15 +0100
committerMarc André Tanner <mat@brain-dump.org>2017-03-01 18:22:13 +0100
commit17786fb0c6982888534885792b390d5ff9f9a342 (patch)
tree5c573cab1e1f66fa218a1535a7b565a41db612ae /lua
parent32ed959c6e2e7729ec4fba11a0274680703e4974 (diff)
downloadvis-17786fb0c6982888534885792b390d5ff9f9a342.tar.gz
vis-17786fb0c6982888534885792b390d5ff9f9a342.tar.xz
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.
Diffstat (limited to 'lua')
-rw-r--r--lua/vis-std.lua4
1 files changed, 3 insertions, 1 deletions
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