Skip to content

Commit

Permalink
Merge pull request #7 from thegecko/config-save-layout
Browse files Browse the repository at this point in the history
Add Save Layout setting
  • Loading branch information
haneefdm authored Apr 14, 2023
2 parents cd71f20 + 0ea9707 commit 7bed570
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,11 @@
"maximum": 2,
"multipleOf": 1,
"description": "Enable debug output in the OUTPUT Tab (Peripheral Viewer section). Some debug output may also be found in the `Mcu-debug Tracker` section which is controlled separately. Changing this value requires a Reload of the window"
},
"mcu-debug.peripheral-viewer.saveLayout": {
"type": "boolean",
"default": true,
"description": "Save layout of peripheral view between sessions"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export const CONFIG_ADDRGAP = 'svdAddrGapThreshold';
export const DEFAULT_ADDRGAP = 16;
export const CONFIG_ASSET_PATH = 'packAssetUrl';
export const DEFAULT_ASSET_PATH = 'https://pack-asset-service.keil.arm.com';
export const CONFIG_SAVE_LAYOUT = 'saveLayout';
export const DEBUG_LEVEL = 'debugLevel';
8 changes: 7 additions & 1 deletion src/views/peripheral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,19 @@ export class PeripheralTreeForSession extends PeripheralBaseNode {
}

private async loadSvdState(context: vscode.ExtensionContext): Promise<NodeSetting[]> {
const saveLayout = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get<boolean>(manifest.CONFIG_SAVE_LAYOUT);
if (!saveLayout) {
return [];
}

const propName = PeripheralTreeForSession.getStatePropName(this.session);
const state = context.workspaceState.get(propName) as NodeSetting[] || [];
return state;
}

private async saveSvdState(state: NodeSetting[], context: vscode.ExtensionContext): Promise<void> {
if (this.session) {
const saveLayout = vscode.workspace.getConfiguration(manifest.PACKAGE_NAME).get<boolean>(manifest.CONFIG_SAVE_LAYOUT);
if (saveLayout && this.session) {
const propName = PeripheralTreeForSession.getStatePropName(this.session);
context.workspaceState.update(propName, state);
}
Expand Down

0 comments on commit 7bed570

Please sign in to comment.