- commit
- 579f4bfc29aa1c919e59db18404e264ecde784bc
- parent
- 64535efb59d2dd79b7c1fc753a193366872f7105
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2023-05-29 15:10
pass buffer number to channel callback
Diffstat
M | autoload/pad.vim | 4 | ++-- |
M | python/pad/__init__.py | 6 | +++--- |
2 files changed, 5 insertions, 5 deletions
diff --git a/autoload/pad.vim b/autoload/pad.vim
@@ -11,6 +11,6 @@ function pad#on_open() 11 11 py3 pad.on_open() 12 12 endfunction 13 1314 -1 function pad#on_channel(channel, msg)15 -1 exe 'py3 pad.on_channel("' . escape(a:msg, '"\\') . '")'-1 14 function pad#on_channel(buffer, channel, msg) -1 15 exe 'py3 pad.on_channel(' . a:buffer . ', "' . escape(a:msg, '"\\') . '")' 16 16 endfunction
diff --git a/python/pad/__init__.py b/python/pad/__init__.py
@@ -31,7 +31,7 @@ class Pad: 31 31 vim.command( 32 32 f'let g:pad_curl_{self.buffer.number} = job_start(' 33 33 f'["curl", "-N", "{self.url}"], '34 -1 '{"out_cb": "pad#on_channel"}'-1 34 f'{{"out_cb": function("pad#on_channel", [{self.buffer.number}])}}' 35 35 ')' 36 36 ) 37 37 @@ -119,12 +119,12 @@ def on_close(): 119 119 pad.stop_listen() 120 120 121 121122 -1 def on_channel(msg):-1 122 def on_channel(i, msg): 123 123 if not msg.startswith('data: '): 124 124 return 125 125 data = json.loads(msg.split(': ', 1)[1]) 126 126 if data[1] == 'changes':127 -1 pad = pads[vim.current.buffer]-1 127 pad = pads[i] 128 128 if data[0] == pad.id: 129 129 pad.staged_changes = [] 130 130 else: