martanne / vis

A vi-like editor based on Plan 9's structural regular expressions
Other
4.19k stars 260 forks source link

When Remapping Delete Operator, Pressing the New Mapping Twice Deletes 2 Lines #1183

Closed VehementHam closed 2 months ago

VehementHam commented 2 months ago

Problem

After remapping the delete operator (i.e. to k), when pressing the newly mapped key twice, it deletes 2 lines. The action should only delete one line. Pressing the default delete operator d twice only deletes one line, of course when the binding for d has not been changed.

Steps to reproduce

Use this config:

-- ...

vis.events.subscribe(vis.events.INIT, function()
    -- Your global configuration options
    -- key mappings
    vis:map(vis.modes.NORMAL, "d", "<Left>")
    vis:map(vis.modes.NORMAL, "h", "<Down>")
    vis:map(vis.modes.NORMAL, "t", "<Up>")
    vis:map(vis.modes.NORMAL, "n", "<Right>")
    vis:map(vis.modes.NORMAL, "l", "<vis-motion-search-repeat>")
    vis:map(vis.modes.NORMAL, "L", "<vis-motion-search-repeat-backward>")
    vis:map(vis.modes.NORMAL, "k", "<vis-operator-delete>")
end)

vis.events.subscribe(vis.events.WIN_OPEN, function(win) -- luacheck: no unused args
    -- Your per window configuration options e.g.
    vis:command('set theme base16-tomorrow-night')
    vis:command('set number')
    vis:command('set cursorline')
end)

-- ...

vis version (vis -v)

vis 0.8 +curses +lua +acl

Terminal name/version

foot version: 1.17.2 +pgo +ime +graphemes -assertions

$TERM environment variable

xterm-256color

VehementHam commented 2 months ago

My theory is that when k is pressed twice, it acts as up on press 2. Basically k was never remapped for delete mode.

VehementHam commented 2 months ago

I see the issue. I never remaped for OPERATOR-PENDING.