Skip to content

fix: make Keybinding work after reloading Molecule #686

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/provider/molecule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ export class MoleculeProvider extends Component<IMoleculeProps> {
}

componentDidMount() {
// The monacoService needs to be initialized each time the MoleculeProvider is loaded to
// ensure that Keybinding events can be bound to the latest dom.
this.monacoService.initWorkspace(this.layoutService.container!);

if (!this.extensionService.isLoaded()) {
this.initialize();
}
Expand All @@ -59,9 +63,6 @@ export class MoleculeProvider extends Component<IMoleculeProps> {
const [languages, restExts] =
this.extensionService.splitLanguagesExts(extensions);

// First to init the monacoService
this.monacoService.initWorkspace(this.layoutService.container!);

// Molecule should load the language extensions first to
// ensure that the custom language extensions is registered in localeService
this.initLocaleExts(languages);
Expand Down
5 changes: 2 additions & 3 deletions src/services/workbench/layoutService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,8 @@ export class LayoutService
}

public get container() {
if (!this._container) {
this._container = document.getElementById(ID_APP) || document.body;
}
// Make sure to get the latest dom element.
this._container = document.getElementById(ID_APP) || document.body;
return this._container;
}

Expand Down