@@ -19,13 +19,14 @@ import { HistoryNavigator } from 'vs/base/common/history';
19
19
import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
20
20
import { Disposable , IDisposable } from 'vs/base/common/lifecycle' ;
21
21
import { removeAnsiEscapeCodes } from 'vs/base/common/strings' ;
22
+ import { ThemeIcon } from 'vs/base/common/themables' ;
22
23
import { URI as uri } from 'vs/base/common/uri' ;
23
24
import 'vs/css!./media/repl' ;
24
25
import { ICodeEditor , isCodeEditor } from 'vs/editor/browser/editorBrowser' ;
25
26
import { EditorAction , registerEditorAction } from 'vs/editor/browser/editorExtensions' ;
26
27
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService' ;
27
28
import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget' ;
28
- import { EditorOption , EDITOR_FONT_DEFAULTS } from 'vs/editor/common/config/editorOptions' ;
29
+ import { EDITOR_FONT_DEFAULTS , EditorOption } from 'vs/editor/common/config/editorOptions' ;
29
30
import { Position } from 'vs/editor/common/core/position' ;
30
31
import { Range } from 'vs/editor/common/core/range' ;
31
32
import { IDecorationOptions } from 'vs/editor/common/editorCommon' ;
@@ -55,18 +56,17 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
55
56
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry' ;
56
57
import { editorForeground , resolveColorValue } from 'vs/platform/theme/common/colorRegistry' ;
57
58
import { IThemeService } from 'vs/platform/theme/common/themeService' ;
58
- import { ThemeIcon } from 'vs/base/common/themables' ;
59
59
import { FilterViewPane , IViewPaneOptions , ViewAction } from 'vs/workbench/browser/parts/views/viewPane' ;
60
60
import { IViewDescriptorService , IViewsService } from 'vs/workbench/common/views' ;
61
61
import { getSimpleCodeEditorWidgetOptions , getSimpleEditorOptions } from 'vs/workbench/contrib/codeEditor/browser/simpleEditorOptions' ;
62
62
import { FocusSessionActionViewItem } from 'vs/workbench/contrib/debug/browser/debugActionViewItems' ;
63
63
import { debugConsoleClearAll , debugConsoleEvaluationPrompt } from 'vs/workbench/contrib/debug/browser/debugIcons' ;
64
64
import { LinkDetector } from 'vs/workbench/contrib/debug/browser/linkDetector' ;
65
65
import { ReplFilter } from 'vs/workbench/contrib/debug/browser/replFilter' ;
66
- import { ReplAccessibilityProvider , ReplDataSource , ReplDelegate , ReplEvaluationInputsRenderer , ReplEvaluationResultsRenderer , ReplGroupRenderer , ReplRawObjectsRenderer , ReplOutputElementRenderer , ReplVariablesRenderer } from 'vs/workbench/contrib/debug/browser/replViewer' ;
67
- import { CONTEXT_DEBUG_STATE , CONTEXT_IN_DEBUG_REPL , CONTEXT_MULTI_SESSION_REPL , DEBUG_SCHEME , getStateLabel , IDebugConfiguration , IDebugService , IDebugSession , IReplConfiguration , IReplElement , IReplOptions , REPL_VIEW_ID , State } from 'vs/workbench/contrib/debug/common/debug' ;
66
+ import { ReplAccessibilityProvider , ReplDataSource , ReplDelegate , ReplEvaluationInputsRenderer , ReplEvaluationResultsRenderer , ReplGroupRenderer , ReplOutputElementRenderer , ReplRawObjectsRenderer , ReplVariablesRenderer } from 'vs/workbench/contrib/debug/browser/replViewer' ;
67
+ import { CONTEXT_DEBUG_STATE , CONTEXT_IN_DEBUG_REPL , CONTEXT_MULTI_SESSION_REPL , DEBUG_SCHEME , IDebugConfiguration , IDebugService , IDebugSession , IReplConfiguration , IReplElement , IReplOptions , REPL_VIEW_ID , State , getStateLabel } from 'vs/workbench/contrib/debug/common/debug' ;
68
68
import { Variable } from 'vs/workbench/contrib/debug/common/debugModel' ;
69
- import { ReplGroup } from 'vs/workbench/contrib/debug/common/replModel' ;
69
+ import { ReplEvaluationResult , ReplGroup } from 'vs/workbench/contrib/debug/common/replModel' ;
70
70
import { IEditorService } from 'vs/workbench/services/editor/common/editorService' ;
71
71
72
72
const $ = dom . $ ;
@@ -1045,12 +1045,33 @@ registerAction2(class extends Action2 {
1045
1045
1046
1046
async run ( accessor : ServicesAccessor , element : IReplElement ) : Promise < void > {
1047
1047
const clipboardService = accessor . get ( IClipboardService ) ;
1048
+ const debugService = accessor . get ( IDebugService ) ;
1048
1049
const nativeSelection = window . getSelection ( ) ;
1049
1050
const selectedText = nativeSelection ?. toString ( ) ;
1050
1051
if ( selectedText && selectedText . length > 0 ) {
1051
- await clipboardService . writeText ( selectedText ) ;
1052
+ return clipboardService . writeText ( selectedText ) ;
1052
1053
} else if ( element ) {
1053
- await clipboardService . writeText ( element . toString ( ) ) ;
1054
+ return clipboardService . writeText ( await this . tryEvaluateAndCopy ( debugService , element ) || element . toString ( ) ) ;
1055
+ }
1056
+ }
1057
+
1058
+ private async tryEvaluateAndCopy ( debugService : IDebugService , element : IReplElement ) : Promise < string | undefined > {
1059
+ // todo: we should expand DAP to allow copying more types here (#187784)
1060
+ if ( ! ( element instanceof ReplEvaluationResult ) ) {
1061
+ return ;
1062
+ }
1063
+
1064
+ const stackFrame = debugService . getViewModel ( ) . focusedStackFrame ;
1065
+ const session = debugService . getViewModel ( ) . focusedSession ;
1066
+ if ( ! stackFrame || ! session || ! session . capabilities . supportsClipboardContext ) {
1067
+ return ;
1068
+ }
1069
+
1070
+ try {
1071
+ const evaluation = await session . evaluate ( element . originalExpression , stackFrame . frameId , 'clipboard' ) ;
1072
+ return evaluation ?. body . result ;
1073
+ } catch ( e ) {
1074
+ return ;
1054
1075
}
1055
1076
}
1056
1077
} ) ;
0 commit comments