more keybindings w copilot tests (#2875)

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-07-02 10:08:02 -07:00
committed by GitHub
parent 39126dbff1
commit c5150468a2
2 changed files with 131 additions and 18 deletions

View File

@ -624,6 +624,16 @@ export const copilotPlugin = (options: LanguageServerOptions): Extension => {
},
})
const rejectSuggestionCommand = (view: EditorView): boolean => {
if (view.plugin === null) return false
// Get the current plugin from the map.
const p = view.plugin(completionPlugin)
if (p === null) return false
return p.rejectSuggestionCommand()
}
const copilotAutocompleteKeymap: readonly KeyBinding[] = [
{
key: 'Tab',
@ -639,27 +649,30 @@ export const copilotPlugin = (options: LanguageServerOptions): Extension => {
},
{
key: 'Backspace',
run: (view: EditorView): boolean => {
if (view.plugin === null) return false
// Get the current plugin from the map.
const p = view.plugin(completionPlugin)
if (p === null) return false
return p.rejectSuggestionCommand()
},
run: rejectSuggestionCommand,
},
{
key: 'Delete',
run: (view: EditorView): boolean => {
if (view.plugin === null) return false
// Get the current plugin from the map.
const p = view.plugin(completionPlugin)
if (p === null) return false
return p.rejectSuggestionCommand()
},
run: rejectSuggestionCommand,
},
{ key: 'Mod-z', run: rejectSuggestionCommand, preventDefault: true },
{
key: 'Mod-y',
mac: 'Mod-Shift-z',
run: rejectSuggestionCommand,
preventDefault: true,
},
{
linux: 'Ctrl-Shift-z',
run: rejectSuggestionCommand,
preventDefault: true,
},
{ key: 'Mod-u', run: rejectSuggestionCommand, preventDefault: true },
{
key: 'Alt-u',
mac: 'Mod-Shift-u',
run: rejectSuggestionCommand,
preventDefault: true,
},
]