@@ -9,7 +9,7 @@ import type { Unicode11Addon as Unicode11AddonType } from '@xterm/addon-unicode1
9
9
import type { WebglAddon as WebglAddonType } from '@xterm/addon-webgl' ;
10
10
import type { SerializeAddon as SerializeAddonType } from '@xterm/addon-serialize' ;
11
11
import type { ImageAddon as ImageAddonType } from '@xterm/addon-image' ;
12
- import type { ClipboardAddon as ClipboardAddonType } from '@xterm/addon-clipboard' ;
12
+ import type { ClipboardAddon as ClipboardAddonType , ClipboardSelectionType } from '@xterm/addon-clipboard' ;
13
13
import * as dom from 'vs/base/browser/dom' ;
14
14
import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private' ;
15
15
import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
@@ -40,12 +40,12 @@ import { MouseWheelClassifier } from 'vs/base/browser/ui/scrollbar/scrollableEle
40
40
import { IMouseWheelEvent , StandardWheelEvent } from 'vs/base/browser/mouseEvent' ;
41
41
import { ILayoutService } from 'vs/platform/layout/browser/layoutService' ;
42
42
import { AccessibilitySignal , IAccessibilitySignalService } from 'vs/platform/accessibilitySignal/browser/accessibilitySignalService' ;
43
- import { VscodeClipboardAddon } from 'vs/workbench/contrib/terminal/browser/xterm/vscodeClipboardAddon' ;
44
43
45
44
const enum RenderConstants {
46
45
SmoothScrollDuration = 125
47
46
}
48
47
48
+ let ClipboardAddon : typeof ClipboardAddonType ;
49
49
let ImageAddon : typeof ImageAddonType ;
50
50
let SearchAddon : typeof SearchAddonType ;
51
51
let SerializeAddon : typeof SerializeAddonType ;
@@ -119,7 +119,9 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
119
119
private _markNavigationAddon : MarkNavigationAddon ;
120
120
private _shellIntegrationAddon : ShellIntegrationAddon ;
121
121
private _decorationAddon : DecorationAddon ;
122
- private _clipboardAddon : ClipboardAddonType ;
122
+
123
+ // Always on dynamicly imported addons
124
+ private _clipboardAddon ?: ClipboardAddonType ;
123
125
124
126
// Optional addons
125
127
private _searchAddon ?: SearchAddonType ;
@@ -276,8 +278,17 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
276
278
this . raw . loadAddon ( this . _decorationAddon ) ;
277
279
this . _shellIntegrationAddon = new ShellIntegrationAddon ( shellIntegrationNonce , disableShellIntegrationReporting , this . _telemetryService , this . _logService ) ;
278
280
this . raw . loadAddon ( this . _shellIntegrationAddon ) ;
279
- this . _clipboardAddon = this . _instantiationService . createInstance ( VscodeClipboardAddon ) ;
280
- this . raw . loadAddon ( this . _clipboardAddon ) ;
281
+ this . _getClipboardAddonConstructor ( ) . then ( ClipboardAddon => {
282
+ this . _clipboardAddon = this . _instantiationService . createInstance ( ClipboardAddon , undefined , {
283
+ async readText ( type : ClipboardSelectionType ) : Promise < string > {
284
+ return _clipboardService . readText ( type === 'p' ? 'selection' : 'clipboard' ) ;
285
+ } ,
286
+ async writeText ( type : ClipboardSelectionType , text : string ) : Promise < void > {
287
+ return _clipboardService . writeText ( text , type === 'p' ? 'selection' : 'clipboard' ) ;
288
+ }
289
+ } ) ;
290
+ this . raw . loadAddon ( this . _clipboardAddon ) ;
291
+ } ) ;
281
292
282
293
this . _anyTerminalFocusContextKey = TerminalContextKeys . focusInAny . bindTo ( contextKeyService ) ;
283
294
this . _anyFocusedTerminalHasSelection = TerminalContextKeys . textSelectedInFocused . bindTo ( contextKeyService ) ;
@@ -330,7 +341,7 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
330
341
this . raw . open ( container ) ;
331
342
}
332
343
333
- // TODO: Move before open to the DOM renderer doesn't initialize
344
+ // TODO: Move before open so the DOM renderer doesn't initialize
334
345
if ( options . enableGpu ) {
335
346
if ( this . _shouldLoadWebgl ( ) ) {
336
347
this . _enableWebglRenderer ( ) ;
@@ -715,6 +726,13 @@ export class XtermTerminal extends Disposable implements IXtermTerminal, IDetach
715
726
}
716
727
}
717
728
729
+ protected async _getClipboardAddonConstructor ( ) : Promise < typeof ClipboardAddonType > {
730
+ if ( ! ClipboardAddon ) {
731
+ ClipboardAddon = ( await importAMDNodeModule < typeof import ( '@xterm/addon-clipboard' ) > ( '@xterm/addon-clipboard' , 'lib/addon-clipboard.js' ) ) . ClipboardAddon ;
732
+ }
733
+ return ClipboardAddon ;
734
+ }
735
+
718
736
protected async _getImageAddonConstructor ( ) : Promise < typeof ImageAddonType > {
719
737
if ( ! ImageAddon ) {
720
738
ImageAddon = ( await importAMDNodeModule < typeof import ( '@xterm/addon-image' ) > ( '@xterm/addon-image' , 'lib/addon-image.js' ) ) . ImageAddon ;
0 commit comments