Skip to content

Commit c485164

Browse files
committed
feat: Add support for clipboard context using var_export
1 parent 4df70ce commit c485164

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/phpDebug.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ class PhpDebugSession extends vscode.DebugSession {
241241
],
242242
supportTerminateDebuggee: true,
243243
supportsDelayedStackTraceLoading: false,
244+
supportsClipboardContext: true,
244245
}
245246
this.sendResponse(response)
246247
}
@@ -1441,6 +1442,17 @@ class PhpDebugSession extends vscode.DebugSession {
14411442
if (response.property) {
14421443
result = response.property
14431444
}
1445+
} else if (args.context === 'clipboard') {
1446+
const uuid = randomUUID()
1447+
await connection.sendEvalCommand(`$GLOBALS['eval_cache']['${uuid}']=var_export(${args.expression}, true)`)
1448+
const ctx = await stackFrame.getContexts() // TODO CACHE THIS
1449+
const res = await connection.sendPropertyGetNameCommand(`$eval_cache['${uuid}']`, ctx[1])
1450+
if (res.property) {
1451+
// force a string response
1452+
response.body = { result: res.property.value, variablesReference: 0 }
1453+
this.sendResponse(response)
1454+
return
1455+
}
14441456
} else {
14451457
const response = await connection.sendEvalCommand(args.expression)
14461458
if (response.result) {

src/test/adapter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ describe('PHP Debug Adapter', () => {
827827
await Promise.all([client.launch({ maxConnections: 1, log: true }), client.configurationSequence()])
828828

829829
const s1 = net.createConnection({ port: 9003 })
830-
await client.assertOutput('console', 'new connection 1 from ')
830+
await client.assertOutput('console', 'new connection ')
831831
net.createConnection({ port: 9003 })
832832
const o = await client.waitForEvent('output')
833833
assert.match(

0 commit comments

Comments
 (0)