Skip to content

Commit feb4831

Browse files
author
Loïc Mangeonjean
committed
feat(demo): demo custom action keybindings
1 parent 2d8042f commit feb4831

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

demo/src/main.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as monaco from 'monaco-editor'
33
import { createConfiguredEditor, createModelReference } from 'vscode/monaco'
44
import { registerFileSystemOverlay, HTMLFileSystemProvider } from 'vscode/service-override/files'
55
import * as vscode from 'vscode'
6-
import { ILogService, StandaloneServices, IPreferencesService, IEditorService, IDialogService } from 'vscode/services'
6+
import { ILogService, StandaloneServices, IPreferencesService, IEditorService, IDialogService, getService } from 'vscode/services'
77
import { ConfirmResult, Parts, isPartVisibile, setPartVisibility } from 'vscode/service-override/views'
88
import { clearStorage } from './setup'
99
import { CustomEditorInput } from './features/customView'
@@ -114,11 +114,23 @@ const settingsModelReference = await createModelReference(monaco.Uri.from({ sche
114114
"terminal.integrated.tabs.title": "\${sequence}",
115115
"typescript.tsserver.log": "normal"
116116
}`)
117-
createConfiguredEditor(document.getElementById('settings-editor')!, {
117+
const settingEditor = createConfiguredEditor(document.getElementById('settings-editor')!, {
118118
model: settingsModelReference.object.textEditorModel,
119119
automaticLayout: true
120120
})
121121

122+
settingEditor.addAction({
123+
id: 'custom-action',
124+
async run () {
125+
void (await getService(IDialogService)).info('Custom action executed!')
126+
},
127+
label: 'Custom action visible in the command palette',
128+
keybindings: [
129+
monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyK
130+
],
131+
contextMenuGroupId: 'custom'
132+
})
133+
122134
const keybindingsModelReference = await createModelReference(monaco.Uri.from({ scheme: 'user', path: '/keybindings.json' }), `[
123135
{
124136
"key": "ctrl+d",

0 commit comments

Comments
 (0)