A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/0347875a5c11258ebb6377a1ab79b04fe9c55bc9 below:

ignore nore on <Plug> maps · neovim/neovim@0347875 · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+52

-2

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+52

-2

lines changed Original file line number Diff line number Diff line change

@@ -65,6 +65,9 @@ modes.

65 65

where the map command applies. Disallow mapping of

66 66

{rhs}, to avoid nested and recursive mappings. Often

67 67

used to redefine a command.

68 +

Note: "nore" is ignored for a mapping whose result

69 +

starts with <Plug>. <Plug> is always remapped even if

70 +

"nore" is used.

68 71 69 72 70 73

:unm[ap] {lhs} |mapmode-nvo| *:unm* *:unmap*

Original file line number Diff line number Diff line change

@@ -442,6 +442,9 @@ Working directory (Vim implemented some of these later than Nvim):

442 442

- `getcwd(-1)` is equivalent to `getcwd(-1, 0)` instead of returning the global

443 443

working directory. Use `getcwd(-1, -1)` to get the global working directory.

444 444 445 +

Mappings:

446 +

- |nore| is ignored for rhs <Plug> mappings. <Plug> mappings are always remapped.

447 + 445 448

==============================================================================

446 449

5. Missing legacy features *nvim-features-missing*

447 450 Original file line number Diff line number Diff line change

@@ -1710,6 +1710,15 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)

1710 1710

int keylen = *keylenp;

1711 1711

int i;

1712 1712

int local_State = get_real_state();

1713 +

bool is_plug_map = false;

1714 + 1715 +

// Check if typehead starts with a <Plug> mapping.

1716 +

// In that case we will ignore nore flag on it.

1717 +

if (typebuf.tb_buf[typebuf.tb_off] == K_SPECIAL

1718 +

&& typebuf.tb_buf[typebuf.tb_off+1] == KS_EXTRA

1719 +

&& typebuf.tb_buf[typebuf.tb_off+2] == KE_PLUG) {

1720 +

is_plug_map = true;

1721 +

}

1713 1722 1714 1723

// Check for a mappable key sequence.

1715 1724

// Walk through one maphash[] list until we find an entry that matches.

@@ -1725,7 +1734,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)

1725 1734

tb_c1 = typebuf.tb_buf[typebuf.tb_off];

1726 1735

if (no_mapping == 0 && maphash_valid

1727 1736

&& (no_zero_mapping == 0 || tb_c1 != '0')

1728 -

&& (typebuf.tb_maplen == 0

1737 +

&& (typebuf.tb_maplen == 0 || is_plug_map

1729 1738

|| (p_remap

1730 1739

&& !(typebuf.tb_noremap[typebuf.tb_off] & (RM_NONE|RM_ABBR))))

1731 1740

&& !(p_paste && (State & (INSERT + CMDLINE)))

@@ -1813,7 +1822,7 @@ static int handle_mapping(int *keylenp, bool *timedout, int *mapdepth)

1813 1822

break;

1814 1823

}

1815 1824

}

1816 -

if (n >= 0) {

1825 +

if (!is_plug_map && n >= 0) {

1817 1826

continue;

1818 1827

}

1819 1828 Original file line number Diff line number Diff line change

@@ -6,6 +6,8 @@ local meths = helpers.meths

6 6

local clear = helpers.clear

7 7

local command = helpers.command

8 8

local expect = helpers.expect

9 +

local insert = helpers.insert

10 +

local eval = helpers.eval

9 11 10 12

describe(':*map', function()

11 13

before_each(clear)

@@ -25,4 +27,37 @@ describe(':*map', function()

25 27

feed('i-<M-">-')

26 28

expect('-foo-')

27 29

end)

30 + 31 +

it('<Plug> keymaps ignore nore', function()

32 +

command('let x = 0')

33 +

eq(0, meths.eval('x'))

34 +

command [[

35 +

nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>

36 +

nmap increase_x_remap <Plug>(Increase_x)

37 +

nnoremap increase_x_noremap <Plug>(Increase_x)

38 +

]]

39 +

feed('increase_x_remap')

40 +

eq(1, meths.eval('x'))

41 +

feed('increase_x_noremap')

42 +

eq(2, meths.eval('x'))

43 +

end)

44 +

it("Doesn't auto ignore nore for keys before or after <Plug> keymap", function()

45 +

command('let x = 0')

46 +

eq(0, meths.eval('x'))

47 +

command [[

48 +

nnoremap x <nop>

49 +

nnoremap <Plug>(Increase_x) <cmd>let x+=1<cr>

50 +

nmap increase_x_remap x<Plug>(Increase_x)x

51 +

nnoremap increase_x_noremap x<Plug>(Increase_x)x

52 +

]]

53 +

insert("Some text")

54 +

eq('Some text', eval("getline('.')"))

55 + 56 +

feed('increase_x_remap')

57 +

eq(1, meths.eval('x'))

58 +

eq('Some text', eval("getline('.')"))

59 +

feed('increase_x_noremap')

60 +

eq(2, meths.eval('x'))

61 +

eq('Some te', eval("getline('.')"))

62 +

end)

28 63

end)

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4