1717/* eslint-disable @typescript-eslint/no-explicit-any */
1818import * as vscode from 'vscode' ;
1919import { debugSessionFactory , extensionContextFactory } from '../../__test__/vscode.factory' ;
20- import { LiveWatchValue , LiveWatchTreeDataProvider } from './live-watch' ;
20+ import { LiveWatchValue , LiveWatchTreeDataProvider , LiveWatchNode } from './live-watch' ;
2121import { GDBTargetDebugSession , GDBTargetDebugTracker } from '../../debug-session' ;
2222import { gdbTargetConfiguration } from '../../debug-configuration/debug-configuration.factory' ;
2323import { GDBTargetConfiguration } from '../../debug-configuration' ;
@@ -31,8 +31,8 @@ describe('LiveWatchTreeDataProvider', () => {
3131 let debugConfig : GDBTargetConfiguration ;
3232
3333 // Helper: create a dummy node
34- function makeNode ( expression = 'x' , value : LiveWatchValue = { result : '1' , variablesReference : 0 } , id = 1 ) {
35- return { id, expression, value, parent : undefined , children : [ ] } ;
34+ function makeNode ( expression = 'x' , value : LiveWatchValue = { result : '1' , variablesReference : 0 } , id = 1 , parent ?: LiveWatchNode ) {
35+ return { id, expression, value, parent : parent , children : [ ] } ;
3636 }
3737
3838 beforeEach ( ( ) => {
@@ -193,13 +193,31 @@ describe('LiveWatchTreeDataProvider', () => {
193193 expect ( node . expression ) . toBe ( 'node-1-renamed' ) ;
194194 } ) ;
195195
196- it ( 'copy copies node expression to clipboard' , async ( ) => {
196+ it ( 'copies node expression to clipboard' , async ( ) => {
197197 const node = makeNode ( 'node-to-copy' , { result : '1' , variablesReference : 0 } , 1 ) ;
198198 ( liveWatchTreeDataProvider as any ) . roots = [ node ] ;
199199 await ( liveWatchTreeDataProvider as any ) . handleCopyCommand ( node ) ;
200200 expect ( vscode . env . clipboard . writeText ) . toHaveBeenCalledWith ( 'node-to-copy' ) ;
201201 } ) ;
202202
203+ it ( 'copies evaluateName of children to clipboard when present' , async ( ) => {
204+ const child = makeNode ( 'childName' , {
205+ result : '42' ,
206+ variablesReference : 0 ,
207+ evaluateName : 'parent.childName'
208+ } , 2 ) ;
209+ ( liveWatchTreeDataProvider as any ) . roots = [ child ] ;
210+ await ( liveWatchTreeDataProvider as any ) . handleCopyCommand ( child ) ;
211+ expect ( vscode . env . clipboard . writeText ) . toHaveBeenCalledWith ( 'parent.childName' ) ;
212+ } ) ;
213+
214+ it ( 'copies expression to clipboard when evaluateName not present' , async ( ) => {
215+ const node = makeNode ( 'myExpression' , { result : '123' , variablesReference : 0 } , 1 ) ;
216+ ( liveWatchTreeDataProvider as any ) . roots = [ node ] ;
217+ await ( liveWatchTreeDataProvider as any ) . handleCopyCommand ( node ) ;
218+ expect ( vscode . env . clipboard . writeText ) . toHaveBeenCalledWith ( 'myExpression' ) ;
219+ } ) ;
220+
203221 it ( 'AddFromSelection adds selected text as new live watch expression to roots' , async ( ) => {
204222 jest . spyOn ( liveWatchTreeDataProvider as any , 'evaluate' ) . mockResolvedValue ( { result : '5678' , variablesReference : 0 } ) ;
205223 // Mock the active text editor with a selection whose active position returns a word range
0 commit comments