File tree 1 file changed +51
-0
lines changed
1 file changed +51
-0
lines changed Original file line number Diff line number Diff line change
1
+ -- luacheck: globals vim
2
+ local connections = require (" acid.connections" )
3
+ local ops = require (" acid.ops" )
4
+ local core = require (" acid.core" )
5
+
6
+ local pwd_to_key = function (pwd )
7
+ if not utils .ends_with (pwd , " /" ) then
8
+ return pwd .. " /"
9
+ end
10
+ return pwd
11
+ end
12
+
13
+ local sessions = {}
14
+
15
+ sessions .store = {}
16
+
17
+
18
+ sessions .register_session = function (connection_ix , session )
19
+ if sessions .store [connection_ix ] == nil then
20
+ sessions .store [connection_ix ] = {
21
+ list = {},
22
+ selected = nil
23
+ }
24
+ end
25
+ table.insert (sessions .store [connection_ix ].list , session )
26
+ sessions .store [connection_ix ].selected = session
27
+ end
28
+
29
+ sessions .filter = function (data , connection_ix )
30
+ connection_ix = connection_ix or connections .peek ()
31
+ local session = sessions .store [connection_ix ]
32
+ if session ~= nil then
33
+ data .session = session .selected
34
+ end
35
+
36
+ return data
37
+ end
38
+
39
+ sessions .new_session = function (connection_ix )
40
+ connection_ix = connection_ix or connections .peek ()
41
+ local handler = function (data )
42
+ sessions .register_session (connection_ix , data [' new-session' ])
43
+ end
44
+
45
+ local conn = connections .store [connection_ix ]
46
+ local clone = ops .clone {}
47
+ core .send (conn , clone .payload (), handler )
48
+ end
49
+
50
+
51
+ return sessions
You can’t perform that action at this time.
0 commit comments