Skip to content

Commit

Permalink
duplicate code into function
Browse files Browse the repository at this point in the history
Signed-off-by: odelia <odelia.zehavi@sap.com>
  • Loading branch information
odelia committed Feb 3, 2021
1 parent ef9d9ee commit 4d61c07
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/editor/src/browser/editor-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,21 @@ export class EditorWidget extends BaseWidget implements SaveableSource, Navigata
super(editor);
this.addClass('theia-editor');
this.toDispose.push(this.editor);
this.toDispose.push(this.editor.onSelectionChanged(() => {
if (this.editor.isFocused()) {
this.selectionService.selection = this.editor;
}
}));
this.toDispose.push(this.editor.onSelectionChanged(() => this.setSelection()));
this.toDispose.push(this.editor.onFocusChanged(() => this.setSelection()));
this.toDispose.push(Disposable.create(() => {
if (this.selectionService.selection === this.editor) {
this.selectionService.selection = undefined;
}
}));
}

setSelection(): void {
if (this.editor.isFocused() && this.selectionService.selection !== this.editor) {
this.selectionService.selection = this.editor;
}
}

get saveable(): Saveable {
return this.editor.document;
}
Expand Down

0 comments on commit 4d61c07

Please sign in to comment.