Skip to content

Commit

Permalink
Merge pull request #225 from mbehr1/feat/seq_to_clipboard
Browse files Browse the repository at this point in the history
feat(sequence): add copy to clipboard for events/sequence
  • Loading branch information
mbehr1 authored Nov 19, 2024
2 parents 94a4f9d + 21a0f97 commit 1740c1e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
10 changes: 10 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,11 @@
"command": "dlt-logs.commentThreadExportAll",
"title": "Export all to clipboard as markup",
"icon": "$(markdown)"
},
{
"command": "dlt-logs.treeItemToClipboard",
"title": "Export to clipboard",
"icon": "$(clippy)"
}
],
"menus": {
Expand Down Expand Up @@ -904,6 +909,11 @@
"command": "dlt-logs.setPosFilter",
"when": "view == dltLifecycleExplorer && viewItem =~ /canSetPosF/",
"group": "inline"
},
{
"command": "dlt-logs.treeItemToClipboard",
"when": "view == dltLifecycleExplorer && viewItem =~ /canCopyToClipboard/",
"group": "inline"
}
],
"editor/title": [
Expand Down
14 changes: 9 additions & 5 deletions src/adltDocumentProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2902,18 +2902,21 @@ export class AdltDocument implements vscode.Disposable {
this._treeEventEmitter.fire(seqNode)
}
// get the full md from the sequence result:
/* todo support export command or preview as md
let tooltipSummary = summary
try {
const resAsMd = seqResultToMdAst(seqResult)
const resAsMarkdown = toMarkdown(
{ type: 'root', children: resAsMd },
{ extensions: [gfmTableToMarkdown({ tablePipeAlign: false })] },
)
tooltipSummary += `\n${resAsMarkdown}`
thisSequenceNode.contextValue = 'canCopyToClipboard'
thisSequenceNode.applyCommand = (command) => {
// command should be 'copyToClipboard' but we can ignore it here
vscode.env.clipboard.writeText(resAsMarkdown)
vscode.window.showInformationMessage(`Exported sequence ${thisSequenceNode.label} to clipboard as markup text`)
}
} catch (e) {
tooltipSummary += `\n... error in generating markdown: ${e}`
}*/
log.warn(`restQueryDocsFilters failed toMarkdown due to: ${e}`)
}
thisSequenceNode.description = summary
//thisSequenceNode.tooltip = new vscode.MarkdownString(tooltipSummary)
//thisSequenceNode.tooltip.supportHtml = true
Expand Down Expand Up @@ -3604,6 +3607,7 @@ export class ADltDocumentProvider implements vscode.FileSystemProvider, /*vscode
case 'setPosFilter':
this.modifyNode(node, 'setPosFilter')
break
case 'copyToClipboard':
case 'save':
if (node.uri !== null && this._documents.get(node.uri.toString()) !== undefined && node.applyCommand) {
node.applyCommand(command)
Expand Down
6 changes: 6 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,12 @@ export function activate(context: vscode.ExtensionContext) {
}),
)

context.subscriptions.push(
vscode.commands.registerCommand('dlt-logs.treeItemToClipboard', async (...args: any[]) => {
adltProvider.onTreeNodeCommand('copyToClipboard', args[0])
}),
)

context.subscriptions.push(
vscode.commands.registerCommand('dlt-logs.openReport', async (...args: any[]) => {
// we can be called with two types of args:
Expand Down

0 comments on commit 1740c1e

Please sign in to comment.