Skip to content

Commit ce41bf7

Browse files
committed
feat(layout): react instantly to color theme changes
1 parent 06ae81b commit ce41bf7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/extension/fbaEditor.ts

+8
Original file line numberDiff line numberDiff line change
@@ -266,9 +266,17 @@ export class FBAEditorProvider implements vscode.CustomTextEditorProvider, vscod
266266
}
267267
});
268268

269+
const changeThemeSubsription = vscode.window.onDidChangeActiveColorTheme((event) => {
270+
postMsgOnceAlive({
271+
type: 'onDidChangeActiveColorTheme',
272+
kind: event.kind // 1 = light, 2 = dark, 3 = high contrast
273+
});
274+
});
275+
269276
// Make sure we get rid of the listener when our editor is closed.
270277
webviewPanel.onDidDispose(() => {
271278
changeDocumentSubscription.dispose();
279+
changeThemeSubsription.dispose();
272280
changeActiveDltDocSubscription.dispose();
273281
});
274282

src/webview/src/App.js

+5
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ export default class App extends Component {
255255
// console.warn(`App.onDidChangeActiveRestQueryDoc attributes=${JSON.stringify(this.state.attributes)}`);
256256
this.setState((state) => { return { attributes: [...state.attributes] }; });
257257
break;
258+
case 'onDidChangeActiveColorTheme':
259+
console.log(`App.onDidChangeActiveColorTheme kind=${msg.kind}`);
260+
// for now simply change title to force render:
261+
this.setState((state) => { return { title: state.title }; });
262+
break;
258263
default:
259264
console.warn(`App received unknown type=${msg.type} msg:`);
260265
console.log(msg);

0 commit comments

Comments
 (0)