ref: remove `count1`

It seems like `math.max` is enough for this purpose
pull/26/head
Iron-E 3 months ago
parent 71dfc3930c
commit 8ace330b9f
No known key found for this signature in database
GPG Key ID: 569E791B76A42A1A

@ -127,14 +127,6 @@ VARIABLES *libmodal-usage-variable
})
<
*libmodal.Mode.count1*
`Mode`.count1
The |v:count1| equivalent of |libmodal.Mode.count|.
Type: ~
|libmodal-Var| of |lua-number|
*libmodal.Mode.exit*
`Mode`.exit
@ -211,7 +203,7 @@ FUNCTIONS *libmodal-usage-function
-- You can also use lua functions
zfc = function() vim.api.nvim_command 'tabnew' end
}
< >vim
<>vim
let s:modeInstruction = {
'zf': 'split',
'zfo': 'vsplit',
@ -225,8 +217,13 @@ FUNCTIONS *libmodal-usage-function
that |getchar()| completes. The user input is received through
`g:{name}ModeInput` (see above).
- |v:count| and |v:count1| are provided through `g:{name}ModeCount`
and `g:{name}ModeCount1` respectively.
- |v:count| is provided through `g:{name}ModeCount`. For |v:count1|
do: >lua
local count1 = math.max(1, count) -- lua
<>vim
let count1 = max(1, count) " vimscript
<
*Error you cannot pass a funcref to Lua from Vimscript!
       - If you want to use a |funcref()| for {instruction}, it

@ -15,7 +15,6 @@ local utils = require 'libmodal.utils' --- @type libmodal.utils
--- @field private popups libmodal.collections.Stack
--- @field private supress_exit boolean
--- @field public count libmodal.utils.Var[number]
--- @field public count1 libmodal.utils.Var[number]
--- @field public exit libmodal.utils.Var[boolean]
--- @field public timeouts? libmodal.utils.Var[boolean]
local Mode = utils.classes.new()
@ -46,7 +45,6 @@ function Mode:execute_instruction(instruction)
end
self.count:set(0)
self.count1:set(1)
self:redraw_virtual_cursor()
end
@ -113,7 +111,6 @@ function Mode:enter()
self.popups:push(utils.Popup.new())
end
self.count1:set(1)
self.count:set(0)
self.exit:set(false)
@ -166,7 +163,6 @@ function Mode:get_user_input()
local oldCount = self.count:get()
local newCount = tonumber(oldCount .. string.char(user_input))
self.count:set(newCount)
self.count1:set(math.max(1, newCount))
end
if not self.supress_exit and user_input == globals.ESC_NR then -- the user wants to exit.
@ -260,7 +256,6 @@ function Mode.new(name, instruction, supress_exit)
local self = setmetatable(
{
count = utils.Var.new(name, 'count'),
count1 = utils.Var.new(name, 'count1'),
exit = utils.Var.new(name, 'exit'),
input = utils.Var.new(name, 'input'),
instruction = instruction,

Loading…
Cancel
Save