diff --git a/package.json b/package.json index f01bce87..c8db58fa 100644 --- a/package.json +++ b/package.json @@ -132,10 +132,15 @@ "title": "Refresh" }, { - "command": "cortex-debug.peripherals.togglePin", - "title": "Toggle Pin", + "command": "cortex-debug.peripherals.pin", + "title": "Pin", "icon": "$(pin)" }, + { + "command": "cortex-debug.peripherals.unpin", + "title": "Unpin", + "icon": "$(pinned)" + }, { "category": "Cortex-Debug", "command": "cortex-debug.examineMemory", @@ -1453,7 +1458,11 @@ "when": "false" }, { - "command": "cortex-debug.peripherals.togglePin", + "command": "cortex-debug.peripherals.pin", + "when": "false" + }, + { + "command": "cortex-debug.peripherals.unpin", "when": "false" }, { @@ -1523,13 +1532,18 @@ }, { "command": "cortex-debug.peripherals.forceRefresh", - "when": "view == cortex-debug.peripherals && viewItem == peripheral" + "when": "view == cortex-debug.peripherals && viewItem =~ /peripheral.*/" }, { - "command": "cortex-debug.peripherals.togglePin", + "command": "cortex-debug.peripherals.pin", "when": "view == cortex-debug.peripherals && viewItem == peripheral", "group": "inline" }, + { + "command": "cortex-debug.peripherals.unpin", + "when": "view == cortex-debug.peripherals && viewItem == peripheral.pinned", + "group": "inline" + }, { "command": "cortex-debug.registers.copyValue", "when": "view == cortex-debug.registers && viewItem == register", diff --git a/src/frontend/extension.ts b/src/frontend/extension.ts index a8571c20..69737cae 100644 --- a/src/frontend/extension.ts +++ b/src/frontend/extension.ts @@ -72,7 +72,8 @@ export class CortexDebugExtension { vscode.commands.registerCommand('cortex-debug.peripherals.copyValue', this.peripheralsCopyValue.bind(this)), vscode.commands.registerCommand('cortex-debug.peripherals.setFormat', this.peripheralsSetFormat.bind(this)), vscode.commands.registerCommand('cortex-debug.peripherals.forceRefresh', this.peripheralsForceRefresh.bind(this)), - vscode.commands.registerCommand('cortex-debug.peripherals.togglePin', this.peripheralsTogglePin.bind(this)), + vscode.commands.registerCommand('cortex-debug.peripherals.pin', this.peripheralsTogglePin.bind(this)), + vscode.commands.registerCommand('cortex-debug.peripherals.unpin', this.peripheralsTogglePin.bind(this)), vscode.commands.registerCommand('cortex-debug.registers.copyValue', this.registersCopyValue.bind(this)), diff --git a/src/frontend/views/nodes/peripheralnode.ts b/src/frontend/views/nodes/peripheralnode.ts index 5d7becab..b850bb1e 100644 --- a/src/frontend/views/nodes/peripheralnode.ts +++ b/src/frontend/views/nodes/peripheralnode.ts @@ -1,4 +1,4 @@ -import { TreeItem, TreeItemCollapsibleState, ThemeIcon } from 'vscode'; +import { TreeItem, TreeItemCollapsibleState } from 'vscode'; import { AccessType } from '../../svd'; import { PeripheralBaseNode } from './basenode'; import { AddrRange, AddressRangesInUse } from '../../addrranges'; @@ -56,11 +56,8 @@ export class PeripheralNode extends PeripheralBaseNode { public getTreeItem(): TreeItem | Promise { const label = `${this.name} @ ${hexFormat(this.baseAddress)}`; const item = new TreeItem(label, this.expanded ? TreeItemCollapsibleState.Expanded : TreeItemCollapsibleState.Collapsed); - item.contextValue = 'peripheral'; + item.contextValue = this.pinned ? 'peripheral.pinned' : 'peripheral'; item.tooltip = this.description; - if (this.pinned) - // TODO: requires to update vscode to new typing dependency - item.iconPath = new ThemeIcon('pinned'); return item; }