Skip to content

Commit 3a4ab59

Browse files
committed
fix: repair neovim job callbacks and vimscript regressions
Fix Neovim signal sending and job output routing, and restore valid Vimscript assignments/escaping that were breaking plumbing and register pastes.
1 parent b5b029c commit 3a4ab59

1 file changed

Lines changed: 28 additions & 23 deletions

File tree

plugin/acme.vim

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ function s:JobKill(job, sig)
207207
let map = {'int': 2, 'hup': 1, 'term': 15, 'kill': 9}
208208
let sig = get(map, sig, 15)
209209
endif
210-
silent! call luaeval("vim.loop.kill(vim.fn.jobpid(_A), _B)", [a:job, sig])
210+
silent! call luaeval('vim.loop.kill(vim.fn.jobpid(_A[1]), _A[2])', [a:job, sig])
211211
else
212212
call job_stop(a:job, a:sig)
213213
endif
@@ -260,9 +260,10 @@ function s:GetJobBufNr(job)
260260
endif
261261
endfunc
262262

263-
function s:NvimOut(id, data, event) dict
264-
if empty(a:data) | return | endif
265-
let b = self.buf
263+
function s:NvimOut(id, data, event)
264+
if empty(a:data) || a:data == [''] | return | endif
265+
let job = get(s:nvim_jobs, a:id, {})
266+
let b = get(job, 'buf', -1)
266267
if bufexists(b)
267268
let mod = getbufvar(b, '&modifiable')
268269
call setbufvar(b, '&modifiable', 1)
@@ -275,12 +276,12 @@ function s:NvimOut(id, data, event) dict
275276
endif
276277
call setbufvar(b, '&modifiable', mod)
277278
endif
278-
if has_key(self, 'callback') && !empty(self.callback)
279-
call call(self.callback, [a:id, ''])
279+
if has_key(job, 'callback') && !empty(job.callback)
280+
call call(job.callback, [a:id, ''])
280281
endif
281282
endfunc
282283

283-
function s:NvimExit(id, status, event) dict
284+
function s:NvimExit(id, status, event)
284285
if has_key(s:nvim_jobs, a:id)
285286
call remove(s:nvim_jobs, a:id)
286287
endif
@@ -292,9 +293,10 @@ function s:JobStartNvim(cmd, outb, ctxb, opts, inp)
292293
\ 'on_exit': function('s:NvimExit'),
293294
\ 'on_stdout': function('s:NvimOut'),
294295
\ 'on_stderr': function('s:NvimOut'),
295-
\ 'buf': a:outb,
296-
\ 'callback': get(a:opts, 'callback', ''),
297296
\ }
297+
if a:inp != ''
298+
let job_opts.stdin = 'pipe'
299+
endif
298300
if has_key(a:opts, 'cwd')
299301
let job_opts.cwd = a:opts.cwd
300302
endif
@@ -304,7 +306,10 @@ function s:JobStartNvim(cmd, outb, ctxb, opts, inp)
304306
if job <= 0
305307
return
306308
endif
307-
let s:nvim_jobs[job] = job_opts
309+
let s:nvim_jobs[job] = {
310+
\ 'buf': a:outb,
311+
\ 'callback': get(a:opts, 'callback', ''),
312+
\ }
308313
call s:Started(job, s:BufWin(a:outb) != 0 ? a:outb : a:ctxb, a:cmd)
309314
if a:inp != ''
310315
call chansend(job, a:inp)
@@ -459,7 +464,7 @@ endfunc
459464
function s:Read(cmd, dir, inp)
460465
let end = getcurpos()[4] > strdisplaywidth(getline('.'))
461466
call setreg('"', s:System(a:cmd, a:dir, a:inp), 'c')
462-
exe 'normal! "'.(end ? 'p' : 'P')
467+
exe 'normal! ""'.(end ? 'p' : 'P')
463468
endfunc
464469

465470
function s:ParseCmd(cmd)
@@ -724,7 +729,7 @@ function s:RgOpen(pos)
724729
return 0
725730
endif
726731
call win_execute(s:plumbwin,
727-
\ 'let s:l = search("\v^(\s*(\d+[-:]|\-\-$))@!", "bnW")')
732+
\ 'let s:l = search("\\v^(\\s*(\\d+[-:]|\\-\\-$))@!", "bnW")')
728733
let f = getbufoneline(winbufnr(s:plumbwin), s:l)
729734
if f != ''
730735
return AcmeOpen(f, a:pos)
@@ -876,7 +881,7 @@ endfunc
876881

877882
function s:Scroll(topline)
878883
let v = winsaveview()
879-
v.topline = a:topline
884+
let v.topline = a:topline
880885
call winrestview(v)
881886
endfunc
882887

@@ -922,8 +927,8 @@ function s:Zoom(w)
922927
break
923928
endif
924929
call win_move_statusline(win_id2win(w) - 1, winheight(w) - s)
925-
h -= s
926-
n -= 1
930+
let h -= s
931+
let n -= 1
927932
endfor
928933
endfunc
929934

@@ -983,8 +988,8 @@ function s:MiddleRelease(click)
983988
let vis = s:clickmode == 'v' && (a:click <= 0 || !s:clicksel)
984989
call s:RestVisual(s:visual)
985990
let b = bufnr()
986-
dir = s:Dir()
987-
w = win_getid()
991+
let dir = s:Dir()
992+
let w = win_getid()
988993
exe win_id2win(s:clickwin).'wincmd w'
989994
if s:Receiver(b)
990995
if w != s:clickwin && s:clickmode == 'v' && a:click > 0
@@ -1028,8 +1033,8 @@ function s:RightRelease(click)
10281033
let cmd = a:click <= 0 || s:clicksel ? s:Sel()[0] : expand('<cWORD>')
10291034
let vis = s:clickmode == 'v' && (a:click <= 0 || !s:clicksel)
10301035
call s:RestVisual(s:visual)
1031-
w = win_getid()
1032-
dir = s:CtxDir()
1036+
let w = win_getid()
1037+
let dir = s:CtxDir()
10331038
exe win_id2win(s:clickwin).'wincmd w'
10341039
call s:Open(cmd, a:click, dir, w)
10351040
endfunc
@@ -1113,10 +1118,10 @@ function s:Change(b, l1, l2, lines)
11131118
endif
11141119
let pos = getcurpos(w)
11151120
let last = line('$', w)
1116-
l = s:Bound(1, a:l1 < 0 ? a:l1 + last + 2 : a:l1, last + 1)
1117-
n = s:Bound(0, (a:l2 < 0 ? a:l2 + last + 2 : a:l2) - l + 1,
1121+
let l = s:Bound(1, a:l1 < 0 ? a:l1 + last + 2 : a:l1, last + 1)
1122+
let n = s:Bound(0, (a:l2 < 0 ? a:l2 + last + 2 : a:l2) - l + 1,
11181123
\ last - l + 1)
1119-
i = min([n, len(a:lines)])
1124+
let i = min([n, len(a:lines)])
11201125
if i > 0
11211126
call setbufline(a:b, l, a:lines[:i-1])
11221127
endif
@@ -1381,4 +1386,4 @@ if s:ctrlexe != ''
13811386
\ })
13821387
endif
13831388
let $EDITOR = s:ctrlexe
1384-
endif
1389+
endif

0 commit comments

Comments
 (0)