@@ -146,22 +146,24 @@ function keymap.apply_keymap_to_current_buffer(keys_to_commands)
146
146
147
147
-- insert mode: uses both snippet and insert commands
148
148
for key , commands in pairs (keys_to_commands ) do
149
- keymap .set (' i' , key , function ()
150
- for _ , command in ipairs (commands ) do
151
- -- special case for fallback
152
- if command == ' fallback' then
153
- return keymap .run_non_blink_keymap (' i' , key )
154
-
155
- -- run user defined functions
156
- elseif type (command ) == ' function' then
157
- if command (require (' blink.cmp' )) then return end
158
-
159
- -- otherwise, run the built-in command
160
- elseif require (' blink.cmp' )[command ]() then
161
- return
149
+ if # commands > 0 then
150
+ keymap .set (' i' , key , function ()
151
+ for _ , command in ipairs (commands ) do
152
+ -- special case for fallback
153
+ if command == ' fallback' then
154
+ return keymap .run_non_blink_keymap (' i' , key )
155
+
156
+ -- run user defined functions
157
+ elseif type (command ) == ' function' then
158
+ if command (require (' blink.cmp' )) then return end
159
+
160
+ -- otherwise, run the built-in command
161
+ elseif require (' blink.cmp' )[command ]() then
162
+ return
163
+ end
162
164
end
163
- end
164
- end )
165
+ end )
166
+ end
165
167
end
166
168
167
169
-- snippet mode
@@ -171,7 +173,7 @@ function keymap.apply_keymap_to_current_buffer(keys_to_commands)
171
173
if vim .tbl_contains (snippet_commands , command ) then has_snippet_command = true end
172
174
end
173
175
174
- if has_snippet_command then
176
+ if has_snippet_command and # commands > 0 then
175
177
keymap .set (' s' , key , function ()
176
178
for _ , command in ipairs (keys_to_commands [key ] or {}) do
177
179
-- special case for fallback
0 commit comments