Skip to content

Commit 9263fc4

Browse files
Copilottimheuer
andauthored
Add column sorting functionality to RESX data grid (#17)
* Implement column sorting functionality for RESX data grid --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: timheuer <[email protected]> Co-authored-by: Tim Heuer <[email protected]>
1 parent e1ffe98 commit 9263fc4

File tree

3 files changed

+330
-13
lines changed

3 files changed

+330
-13
lines changed

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,15 @@
9999
"verbose"
100100
],
101101
"description": "Set the logging level"
102-
},
103-
"resx-editor.generateCode": {
102+
}, "resx-editor.generateCode": {
104103
"type": "boolean",
105104
"default": false,
106105
"description": "Generate .Designer.cs files when modifying RESX files (Experimental)"
106+
},
107+
"resx-editor.enableColumnSorting": {
108+
"type": "boolean",
109+
"default": true,
110+
"description": "Enable column sorting in the ResX editor grid"
107111
}
108112
}
109113
},

src/resxProvider.ts

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,43 @@ export class ResxProvider implements vscode.CustomTextEditorProvider {
7878
catch (e) {
7979
console.log(e);
8080
}
81-
81+
8282
async function updateWebview() {
83+
const config = vscode.workspace.getConfiguration('resx-editor');
84+
const enableColumnSorting = config.get<boolean>('enableColumnSorting', true);
85+
8386
webviewPanel.webview.postMessage({
8487
type: 'update',
8588
text: JSON.stringify(await resx.resx2js(document.getText(), true))
8689
});
90+
91+
webviewPanel.webview.postMessage({
92+
type: 'config',
93+
enableColumnSorting: enableColumnSorting
94+
});
8795
}
88-
96+
8997
const changeDocumentSubscription = vscode.workspace.onDidChangeTextDocument(e => {
9098
if (e.document.uri.toString() === document.uri.toString()) {
9199
updateWebview();
92100
}
93101
});
94102

103+
const changeConfigurationSubscription = vscode.workspace.onDidChangeConfiguration(e => {
104+
if (e.affectsConfiguration('resx-editor.enableColumnSorting')) {
105+
const config = vscode.workspace.getConfiguration('resx-editor');
106+
const enableColumnSorting = config.get<boolean>('enableColumnSorting', true);
107+
108+
webviewPanel.webview.postMessage({
109+
type: 'config',
110+
enableColumnSorting: enableColumnSorting
111+
});
112+
}
113+
});
114+
95115
webviewPanel.onDidDispose(() => {
96116
changeDocumentSubscription.dispose();
117+
changeConfigurationSubscription.dispose();
97118
});
98119

99120
webviewPanel.webview.onDidReceiveMessage(e => {
@@ -118,8 +139,18 @@ export class ResxProvider implements vscode.CustomTextEditorProvider {
118139

119140
}
120141
});
121-
122142
updateWebview();
143+
144+
// Send initial configuration after a small delay to ensure webview is ready
145+
setTimeout(() => {
146+
const config = vscode.workspace.getConfiguration('resx-editor');
147+
const enableColumnSorting = config.get<boolean>('enableColumnSorting', true);
148+
149+
webviewPanel.webview.postMessage({
150+
type: 'config',
151+
enableColumnSorting: enableColumnSorting
152+
});
153+
}, 100);
123154
}
124155

125156
private async updateTextDocument(document: vscode.TextDocument, json: any) {

0 commit comments

Comments
 (0)