aboutsummaryrefslogtreecommitdiff
path: root/test/client/msgpack_rpc_stream.lua
diff options
context:
space:
mode:
authorLewis Russell <lewis6991@gmail.com>2024-01-16 13:26:21 +0000
committerLewis Russell <me@lewisr.dev>2024-01-16 19:11:49 +0000
commit8f02ae82e203920b472d17e75a61763f3a409a7b (patch)
tree4e6379218c7d53d1ba512a2464ec0237365a7bbb /test/client/msgpack_rpc_stream.lua
parent91dc04a5e12a3d0c5be56768ded5971bc80e6f8e (diff)
downloadrneovim-8f02ae82e203920b472d17e75a61763f3a409a7b.tar.gz
rneovim-8f02ae82e203920b472d17e75a61763f3a409a7b.tar.bz2
rneovim-8f02ae82e203920b472d17e75a61763f3a409a7b.zip
test: use integers for API Buffer/Window/Tabpage EXT types
Diffstat (limited to 'test/client/msgpack_rpc_stream.lua')
-rw-r--r--test/client/msgpack_rpc_stream.lua40
1 files changed, 7 insertions, 33 deletions
diff --git a/test/client/msgpack_rpc_stream.lua b/test/client/msgpack_rpc_stream.lua
index c91c4fdc2e..4b4f30e0ec 100644
--- a/test/client/msgpack_rpc_stream.lua
+++ b/test/client/msgpack_rpc_stream.lua
@@ -1,22 +1,5 @@
local mpack = vim.mpack
--- temporary hack to be able to manipulate buffer/window/tabpage
-local Buffer = {}
-Buffer.__index = Buffer
-function Buffer.new(id)
- return setmetatable({ id = id }, Buffer)
-end
-local Window = {}
-Window.__index = Window
-function Window.new(id)
- return setmetatable({ id = id }, Window)
-end
-local Tabpage = {}
-Tabpage.__index = Tabpage
-function Tabpage.new(id)
- return setmetatable({ id = id }, Tabpage)
-end
-
local Response = {}
Response.__index = Response
@@ -45,30 +28,21 @@ MsgpackRpcStream.__index = MsgpackRpcStream
function MsgpackRpcStream.new(stream)
return setmetatable({
_stream = stream,
- _pack = mpack.Packer({
- ext = {
- [Buffer] = function(o)
- return 0, mpack.encode(o.id)
- end,
- [Window] = function(o)
- return 1, mpack.encode(o.id)
- end,
- [Tabpage] = function(o)
- return 2, mpack.encode(o.id)
- end,
- },
- }),
+ _pack = mpack.Packer(),
_session = mpack.Session({
unpack = mpack.Unpacker({
ext = {
+ -- Buffer
[0] = function(_c, s)
- return Buffer.new(mpack.decode(s))
+ return mpack.decode(s)
end,
+ -- Window
[1] = function(_c, s)
- return Window.new(mpack.decode(s))
+ return mpack.decode(s)
end,
+ -- Tabpage
[2] = function(_c, s)
- return Tabpage.new(mpack.decode(s))
+ return mpack.decode(s)
end,
},
}),