@@ -42,6 +42,7 @@ if (options.help) {
4242 process . exit ( 0 ) ;
4343}
4444
45+ const isMac = process . platform === "darwin" ;
4546const logger = new ElectronLogService ( ) ;
4647logger . setLogOptions ( getLogOptions ( options ) ) ;
4748logger . misc ( '[Electron Main] command line arguments' , options ) ;
@@ -163,6 +164,35 @@ async function createWindow() {
163164 win . webContents . on ( 'did-finish-load' , ( ) => {
164165 } ) ;
165166
167+ // monaco-editor electron 34+ paste workaround https://github.com/microsoft/monaco-editor/issues/4855#issuecomment-3184259279
168+ win . webContents . on ( "before-input-event" , ( event , input ) => {
169+ const isCmdOrCtrl = isMac ? input . meta === true : input . control === true ;
170+
171+ const hasShift =
172+ input . shift === true ||
173+ input . modifiers . includes ( "shift" ) ;
174+
175+ const hasAlt =
176+ input . alt === true ||
177+ input . modifiers . includes ( "alt" ) ;
178+
179+ // Prefer code (layout-agnostic)
180+ const isV = input . code === "KeyV" || input . key === "v" ;
181+
182+ const shouldPaste =
183+ input . type === 'keyDown' &&
184+ isCmdOrCtrl &&
185+ ! hasShift &&
186+ ! hasAlt &&
187+ isV ;
188+
189+ if ( shouldPaste ) {
190+ // Native paste path (works with Monaco)
191+ win . webContents . paste ( ) ;
192+ event . preventDefault ( ) ;
193+ }
194+ } )
195+
166196 win . webContents . on ( 'render-process-gone' , ( event , details ) => {
167197 logger . misc ( `[Electron Main] render-process-gone, reason: ${ details . reason } exitCode: ${ details . exitCode } ` ) ;
168198 } ) ;
0 commit comments