Skip to content

Commit fb23c03

Browse files
committed
Bump version to 1.0.1 and add configuration options for preserveFocus and preview.
1 parent c8fd1f4 commit fb23c03

3 files changed

Lines changed: 34 additions & 9 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
"name": "cpp-header-source-pair",
33
"displayName": "cpp-header-source-pair",
44
"description": "A simple plugin to open header files along side source files for C/C++ projects.",
5-
"version": "1.0.0",
6-
"publisher": "spalt_er",
5+
"version": "1.0.1",
6+
"publisher": "spalter",
77
"engines": {
88
"vscode": "^1.96.0"
99
},
1010
"categories": [
1111
"Programming Languages",
1212
"Other"
1313
],
14-
"keywords": ["cpp", "header", "source", "pairing"],
14+
"keywords": [
15+
"cpp",
16+
"header",
17+
"source",
18+
"pairing"
19+
],
1520
"icon": "icon.png",
1621
"activationEvents": [],
1722
"main": "./out/extension.js",
@@ -25,7 +30,22 @@
2530
"command": "cpp-header-source-pair.openPairs",
2631
"title": "Open Pairs (C/C++ Header/Source)"
2732
}
28-
]
33+
],
34+
"configuration": {
35+
"title": "C/C++ Header/Source Pair",
36+
"properties": {
37+
"cpp-header-source-pair.preserveFocus": {
38+
"type": "boolean",
39+
"default": false,
40+
"description": "Whether to preserve focus on the editor after opening a pair."
41+
},
42+
"cpp-header-source-pair.preview": {
43+
"type": "boolean",
44+
"default": false,
45+
"description": "Whether to preview the file before pinning it."
46+
}
47+
}
48+
}
2949
},
3050
"scripts": {
3151
"vscode:prepublish": "npm run compile",
@@ -46,4 +66,4 @@
4666
"@vscode/test-cli": "^0.0.10",
4767
"@vscode/test-electron": "^2.4.1"
4868
}
49-
}
69+
}

src/extension.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ function getPairedFile(currentFile: string, isHeader: boolean): string {
2121
async function openPairs(textDocument: vscode.TextDocument) {
2222
const currentFile = textDocument.fileName;
2323

24+
const preserveFocus = vscode.workspace.getConfiguration('cpp-header-source-pair').get('preserveFocus', true);
25+
const preview = vscode.workspace.getConfiguration('cpp-header-source-pair').get('preview', false);
26+
2427
console.log(`Opening ${textDocument.fileName}`);
2528
const isHeader: boolean = isHeaderFile(currentFile);
2629
const pairedFile: string = getPairedFile(currentFile, isHeader);
@@ -37,13 +40,15 @@ async function openPairs(textDocument: vscode.TextDocument) {
3740
const headerDoc = await vscode.workspace.openTextDocument(headerFile);
3841
await vscode.window.showTextDocument(headerDoc, {
3942
viewColumn: vscode.ViewColumn.One,
40-
preserveFocus: true
43+
preserveFocus: true,
44+
preview: preview
4145
});
4246

4347
const sourceDoc = await vscode.workspace.openTextDocument(sourceFile);
4448
await vscode.window.showTextDocument(sourceDoc, {
4549
viewColumn: vscode.ViewColumn.Two,
46-
preserveFocus: false
50+
preserveFocus: preserveFocus,
51+
preview: preview
4752
});
4853
}
4954
console.log(`Current: ${currentFile}, Paired: ${pairedFile}, IsHeader:${isHeader}`);

0 commit comments

Comments
 (0)