A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/neovim/neovim/commit/8ad60154099678b23b78bc8142a168753f53648c below:

add autocommand event when search wraps around (#8487) · neovim/neovim@8ad6015 · GitHub

File tree Expand file treeCollapse file tree 4 files changed

+62

-0

lines changed

Filter options

Expand file treeCollapse file tree 4 files changed

+62

-0

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

@@ -824,6 +824,10 @@ RemoteReply When a reply from a Vim that functions as

824 824

Note that even if an autocommand is defined,

825 825

the reply should be read with |remote_read()|

826 826

to consume it.

827 +

*SearchWrapped*

828 +

SearchWrapped After making a search with |n| or |N| if the

829 +

search wraps around the document back to

830 +

the start/finish respectively.

827 831

*SessionLoadPost*

828 832

SessionLoadPost After loading the session file created using

829 833

the |:mksession| command.

Original file line number Diff line number Diff line change

@@ -76,6 +76,7 @@ return {

76 76

'QuickFixCmdPre', -- before :make, :grep etc.

77 77

'QuitPre', -- before :quit

78 78

'RemoteReply', -- upon string reception from a remote vim

79 +

'SearchWrapped', -- after the search wrapped around

79 80

'SessionLoadPost', -- after loading a session file

80 81

'ShellCmdPost', -- after ":!cmd"

81 82

'ShellFilterPost', -- after ":1,2!cmd", ":w !cmd", ":r !cmd".

Original file line number Diff line number Diff line change

@@ -1354,6 +1354,10 @@ int do_search(oparg_T *oap, int dirc, int search_delim, char_u *pat, long count,

1354 1354

}

1355 1355

retval = 1; // pattern found

1356 1356 1357 +

if (sia && sia->sa_wrapped) {

1358 +

apply_autocmds(EVENT_SEARCHWRAPPED, NULL, NULL, false, NULL);

1359 +

}

1360 + 1357 1361

/*

1358 1362

* Add character and/or line offset

1359 1363

*/

Original file line number Diff line number Diff line change

@@ -0,0 +1,53 @@

1 +

local helpers = require('test.functional.helpers')(after_each)

2 + 3 +

local clear = helpers.clear

4 +

local command = helpers.command

5 +

local curbufmeths = helpers.curbufmeths

6 +

local eq = helpers.eq

7 +

local eval = helpers.eval

8 +

local feed = helpers.feed

9 + 10 +

describe('autocmd SearchWrapped', function()

11 +

before_each(function()

12 +

clear()

13 +

command('set ignorecase')

14 +

command('let g:test = 0')

15 +

command('autocmd! SearchWrapped * let g:test += 1')

16 +

curbufmeths.set_lines(0, 1, false, {

17 +

'The quick brown fox',

18 +

'jumps over the lazy dog'})

19 +

end)

20 + 21 +

it('gets triggered when search wraps the end', function()

22 +

feed('/the<Return>')

23 +

eq(0, eval('g:test'))

24 + 25 +

feed('n')

26 +

eq(1, eval('g:test'))

27 + 28 +

feed('nn')

29 +

eq(2, eval('g:test'))

30 +

end)

31 + 32 +

it('gets triggered when search wraps in reverse order', function()

33 +

feed('/the<Return>')

34 +

eq(0, eval('g:test'))

35 + 36 +

feed('NN')

37 +

eq(1, eval('g:test'))

38 + 39 +

feed('NN')

40 +

eq(2, eval('g:test'))

41 +

end)

42 + 43 +

it('does not get triggered on failed searches', function()

44 +

feed('/blargh<Return>')

45 +

eq(0, eval('g:test'))

46 + 47 +

feed('NN')

48 +

eq(0, eval('g:test'))

49 + 50 +

feed('NN')

51 +

eq(0, eval('g:test'))

52 +

end)

53 +

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