@@ -7,14 +7,18 @@ import * as nls from 'vs/nls';
77import { Action } from 'vs/base/common/actions' ;
88import { Variable } from 'vs/workbench/contrib/debug/common/debugModel' ;
99import { IDebugService , IStackFrame } from 'vs/workbench/contrib/debug/common/debug' ;
10- import { clipboard } from 'electron' ;
1110import { isWindows } from 'vs/base/common/platform' ;
11+ import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService' ;
1212
1313export class CopyValueAction extends Action {
1414 static readonly ID = 'workbench.debug.viewlet.action.copyValue' ;
1515 static LABEL = nls . localize ( 'copyValue' , "Copy Value" ) ;
1616
17- constructor ( id : string , label : string , private value : any , private context : string , @IDebugService private readonly debugService : IDebugService ) {
17+ constructor (
18+ id : string , label : string , private value : any , private context : string ,
19+ @IDebugService private readonly debugService : IDebugService ,
20+ @IClipboardService private readonly clipboardService : IClipboardService
21+ ) {
1822 super ( id , label , 'debug-action copy-value' ) ;
1923 this . _enabled = typeof this . value === 'string' || ( this . value instanceof Variable && ! ! this . value . evaluateName ) ;
2024 }
@@ -25,11 +29,11 @@ export class CopyValueAction extends Action {
2529
2630 if ( this . value instanceof Variable && stackFrame && session && this . value . evaluateName ) {
2731 return session . evaluate ( this . value . evaluateName , stackFrame . frameId , this . context ) . then ( result => {
28- clipboard . writeText ( result . body . result ) ;
29- } , err => clipboard . writeText ( this . value . value ) ) ;
32+ this . clipboardService . writeText ( result . body . result ) ;
33+ } , err => this . clipboardService . writeText ( this . value . value ) ) ;
3034 }
3135
32- clipboard . writeText ( this . value ) ;
36+ this . clipboardService . writeText ( this . value ) ;
3337 return Promise . resolve ( undefined ) ;
3438 }
3539}
@@ -38,13 +42,16 @@ export class CopyEvaluatePathAction extends Action {
3842 static readonly ID = 'workbench.debug.viewlet.action.copyEvaluatePath' ;
3943 static LABEL = nls . localize ( 'copyAsExpression' , "Copy as Expression" ) ;
4044
41- constructor ( id : string , label : string , private value : Variable ) {
45+ constructor (
46+ id : string , label : string , private value : Variable ,
47+ @IClipboardService private readonly clipboardService : IClipboardService
48+ ) {
4249 super ( id , label ) ;
4350 this . _enabled = this . value && ! ! this . value . evaluateName ;
4451 }
4552
4653 public run ( ) : Promise < any > {
47- clipboard . writeText ( this . value . evaluateName ! ) ;
54+ this . clipboardService . writeText ( this . value . evaluateName ! ) ;
4855 return Promise . resolve ( undefined ) ;
4956 }
5057}
@@ -53,8 +60,15 @@ export class CopyAction extends Action {
5360 static readonly ID = 'workbench.debug.action.copy' ;
5461 static LABEL = nls . localize ( 'copy' , "Copy" ) ;
5562
63+ constructor (
64+ id : string , label : string ,
65+ @IClipboardService private readonly clipboardService : IClipboardService
66+ ) {
67+ super ( id , label ) ;
68+ }
69+
5670 public run ( ) : Promise < any > {
57- clipboard . writeText ( window . getSelection ( ) . toString ( ) ) ;
71+ this . clipboardService . writeText ( window . getSelection ( ) . toString ( ) ) ;
5872 return Promise . resolve ( undefined ) ;
5973 }
6074}
@@ -65,8 +79,15 @@ export class CopyStackTraceAction extends Action {
6579 static readonly ID = 'workbench.action.debug.copyStackTrace' ;
6680 static LABEL = nls . localize ( 'copyStackTrace' , "Copy Call Stack" ) ;
6781
82+ constructor (
83+ id : string , label : string ,
84+ @IClipboardService private readonly clipboardService : IClipboardService
85+ ) {
86+ super ( id , label ) ;
87+ }
88+
6889 public run ( frame : IStackFrame ) : Promise < any > {
69- clipboard . writeText ( frame . thread . getCallStack ( ) . map ( sf => sf . toString ( ) ) . join ( lineDelimiter ) ) ;
90+ this . clipboardService . writeText ( frame . thread . getCallStack ( ) . map ( sf => sf . toString ( ) ) . join ( lineDelimiter ) ) ;
7091 return Promise . resolve ( undefined ) ;
7192 }
7293}
0 commit comments