A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/neovim/neovim/commit/72652cbc46f568128bfc296ba63fb2d26941da8e below:

use nvim_exec in helpers.source() #16064 · neovim/neovim@72652cb · GitHub

1 1

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

2 2

local clear = helpers.clear

3 -

local feed_command = helpers.feed_command

4 3

local feed = helpers.feed

5 4

local eq = helpers.eq

6 5

local expect = helpers.expect

7 6

local eval = helpers.eval

8 7

local funcs = helpers.funcs

9 8

local insert = helpers.insert

9 +

local write_file = helpers.write_file

10 10

local exc_exec = helpers.exc_exec

11 -

local source = helpers.source

11 +

local command = helpers.command

12 12

local Screen = require('test.functional.ui.screen')

13 13 14 14

describe('mappings with <Cmd>', function()

15 15

local screen

16 +

local tmpfile = 'X_ex_cmds_cmd_map'

17 + 16 18

local function cmdmap(lhs, rhs)

17 -

feed_command('noremap '..lhs..' <Cmd>'..rhs..'<cr>')

18 -

feed_command('noremap! '..lhs..' <Cmd>'..rhs..'<cr>')

19 +

command('noremap '..lhs..' <Cmd>'..rhs..'<cr>')

20 +

command('noremap! '..lhs..' <Cmd>'..rhs..'<cr>')

19 21

end

20 22 21 23

before_each(function()

@@ -39,7 +41,7 @@ describe('mappings with <Cmd>', function()

39 41

cmdmap('<F4>', 'normal! ww')

40 42

cmdmap('<F5>', 'normal! "ay')

41 43

cmdmap('<F6>', 'throw "very error"')

42 -

feed_command([[

44 +

command([[

43 45

function! TextObj()

44 46

if mode() !=# "v"

45 47

normal! v

@@ -55,11 +57,15 @@ describe('mappings with <Cmd>', function()

55 57

feed('gg')

56 58

cmdmap('<F8>', 'startinsert')

57 59

cmdmap('<F9>', 'stopinsert')

58 -

feed_command("abbr foo <Cmd>let g:y = 17<cr>bar")

60 +

command("abbr foo <Cmd>let g:y = 17<cr>bar")

61 +

end)

62 + 63 +

after_each(function()

64 +

os.remove(tmpfile)

59 65

end)

60 66 61 67

it('can be displayed', function()

62 -

feed_command('map <F3>')

68 +

command('map <F3>')

63 69

screen:expect([[

64 70

^some short lines |

65 71

of test text |

@@ -73,8 +79,8 @@ describe('mappings with <Cmd>', function()

73 79

end)

74 80 75 81

it('handles invalid mappings', function()

76 -

feed_command('let x = 0')

77 -

feed_command('noremap <F3> <Cmd><Cmd>let x = 1<cr>')

82 +

command('let x = 0')

83 +

command('noremap <F3> <Cmd><Cmd>let x = 1<cr>')

78 84

feed('<F3>')

79 85

screen:expect([[

80 86

^some short lines |

@@ -87,7 +93,7 @@ describe('mappings with <Cmd>', function()

87 93

{2:E5521: <Cmd> mapping must end with <CR> before second <Cmd>} |

88 94

]])

89 95 90 -

feed_command('noremap <F3> <Cmd><F3>let x = 2<cr>')

96 +

command('noremap <F3> <Cmd><F3>let x = 2<cr>')

91 97

feed('<F3>')

92 98

screen:expect([[

93 99

^some short lines |

@@ -100,7 +106,7 @@ describe('mappings with <Cmd>', function()

100 106

{2:E5522: <Cmd> mapping must not include <F3> key} |

101 107

]])

102 108 103 -

feed_command('noremap <F3> <Cmd>let x = 3')

109 +

command('noremap <F3> <Cmd>let x = 3')

104 110

feed('<F3>')

105 111

screen:expect([[

106 112

^some short lines |

@@ -137,7 +143,7 @@ describe('mappings with <Cmd>', function()

137 143

eq('n', eval('mode(1)'))

138 144 139 145

-- select mode mapping

140 -

feed_command('snoremap <F3> <Cmd>let m = mode(1)<cr>')

146 +

command('snoremap <F3> <Cmd>let m = mode(1)<cr>')

141 147

feed('gh<F3>')

142 148

eq('s', eval('m'))

143 149

-- didn't leave select mode

@@ -184,8 +190,8 @@ describe('mappings with <Cmd>', function()

184 190

eq('n', eval('mode(1)'))

185 191 186 192

-- terminal mode

187 -

feed_command('tnoremap <F3> <Cmd>let m = mode(1)<cr>')

188 -

feed_command('split | terminal')

193 +

command('tnoremap <F3> <Cmd>let m = mode(1)<cr>')

194 +

command('split | terminal')

189 195

feed('i')

190 196

eq('t', eval('mode(1)'))

191 197

feed('<F3>')

@@ -264,11 +270,11 @@ describe('mappings with <Cmd>', function()

264 270

end)

265 271 266 272

it('works in :normal command', function()

267 -

feed_command('noremap ,x <Cmd>call append(1, "xx")\\| call append(1, "aa")<cr>')

268 -

feed_command('noremap ,f <Cmd>nosuchcommand<cr>')

269 -

feed_command('noremap ,e <Cmd>throw "very error"\\| call append(1, "yy")<cr>')

270 -

feed_command('noremap ,m <Cmd>echoerr "The message."\\| call append(1, "zz")<cr>')

271 -

feed_command('noremap ,w <Cmd>for i in range(5)\\|if i==1\\|echoerr "Err"\\|endif\\|call append(1, i)\\|endfor<cr>')

273 +

command('noremap ,x <Cmd>call append(1, "xx")\\| call append(1, "aa")<cr>')

274 +

command('noremap ,f <Cmd>nosuchcommand<cr>')

275 +

command('noremap ,e <Cmd>throw "very error"\\| call append(1, "yy")<cr>')

276 +

command('noremap ,m <Cmd>echoerr "The message."\\| call append(1, "zz")<cr>')

277 +

command('noremap ,w <Cmd>for i in range(5)\\|if i==1\\|echoerr "Err"\\|endif\\|call append(1, i)\\|endfor<cr>')

272 278 273 279

feed(":normal ,x<cr>")

274 280

screen:expect([[

@@ -297,7 +303,7 @@ describe('mappings with <Cmd>', function()

297 303

:normal ,x |

298 304

]])

299 305 300 -

feed_command(':%d')

306 +

command(':%d')

301 307

eq('Vim(echoerr):Err', exc_exec("normal ,w"))

302 308

screen:expect([[

303 309

^ |

@@ -310,8 +316,8 @@ describe('mappings with <Cmd>', function()

310 316

--No lines in buffer-- |

311 317

]])

312 318 313 -

feed_command(':%d')

314 -

feed_command(':normal ,w')

319 +

command(':%d')

320 +

feed(':normal ,w<cr>')

315 321

screen:expect([[

316 322

^ |

317 323

4 |

@@ -401,8 +407,8 @@ describe('mappings with <Cmd>', function()

401 407

end)

402 408 403 409

it('works in select mode', function()

404 -

feed_command('snoremap <F1> <cmd>throw "very error"<cr>')

405 -

feed_command('snoremap <F2> <cmd>normal! <c-g>"by<cr>')

410 +

command('snoremap <F1> <cmd>throw "very error"<cr>')

411 +

command('snoremap <F2> <cmd>normal! <c-g>"by<cr>')

406 412

-- can extend select mode

407 413

feed('gh<F4>')

408 414

screen:expect([[

@@ -830,12 +836,14 @@ describe('mappings with <Cmd>', function()

830 836

end)

831 837 832 838

it("works with <SID> mappings", function()

833 -

source([[

839 +

command('new!')

840 +

write_file(tmpfile, [[

834 841

map <f2> <Cmd>call <SID>do_it()<Cr>

835 842

function! s:do_it()

836 843

let g:x = 10

837 844

endfunction

838 845

]])

846 +

command('source '..tmpfile)

839 847

feed('<f2>')

840 848

eq('', eval('v:errmsg'))

841 849

eq(10, eval('g:x'))


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