1
1
local env = require (" tests.env" )
2
- local M = {}
2
+ local M = {
3
+ mock_lsp_server = false ,
4
+ }
3
5
4
6
if not _G .attach_debugger then
5
7
_G .attach_debugger = false
@@ -59,6 +61,7 @@ function M.new_child_neovim(test_name)
59
61
60
62
--- @param mock_lsp_server ? boolean
61
63
function child .run_pre_case (mock_lsp_server )
64
+ M .mock_lsp_server = mock_lsp_server or false
62
65
child .reset_config ()
63
66
child .restart ({ " -u" , " tests/scripts/minimal_init.lua" })
64
67
@@ -124,15 +127,35 @@ function M.new_child_neovim(test_name)
124
127
end
125
128
126
129
function child .wait_for_suggestion ()
127
- child .lua ([[
130
+ if M .mock_lsp_server then
131
+ child .lua ([[
132
+ vim.wait(500, function()
133
+ return M.suggested
134
+ end, 10)
135
+ ]] )
136
+ else
137
+ child .lua ([[
128
138
vim.wait(5000, function()
129
139
return M.suggested
130
140
end, 10)
131
141
]] )
142
+ end
132
143
end
133
144
134
145
function child .wait_for_panel_suggestion ()
135
- child .lua ([[
146
+ if M .mock_lsp_server then
147
+ child .lua ([[
148
+ local function suggestion_is_visible()
149
+ lines = vim.api.nvim_buf_get_lines(2, 4, 5, false)
150
+ return lines[1] and (lines[1] == "789" or lines[1] == "789\r")
151
+ end
152
+
153
+ vim.wait(500, function()
154
+ return suggestion_is_visible()
155
+ end, 50)
156
+ ]] )
157
+ else
158
+ child .lua ([[
136
159
local function suggestion_is_visible()
137
160
lines = vim.api.nvim_buf_get_lines(2, 4, 5, false)
138
161
return lines[1] and (lines[1] == "789" or lines[1] == "789\r")
@@ -142,6 +165,7 @@ function M.new_child_neovim(test_name)
142
165
return suggestion_is_visible()
143
166
end, 50)
144
167
]] )
168
+ end
145
169
end
146
170
147
171
return child
0 commit comments