Skip to content

Commit

Permalink
add resizing to editor input
Browse files Browse the repository at this point in the history
Signed-off-by: Kenneth Marut <kenneth.marut@ericsson.com>
  • Loading branch information
kenneth-marut-work committed Jun 9, 2021
1 parent 93c5c8d commit 64e613f
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/debug/src/browser/editor/debug-breakpoint-widget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { MonacoEditorZoneWidget } from '@theia/monaco/lib/browser/monaco-editor-
import { MonacoEditor } from '@theia/monaco/lib/browser/monaco-editor';
import { DebugEditor } from './debug-editor';
import { DebugSourceBreakpoint } from '../model/debug-source-breakpoint';
import { Dimension } from '@theia/editor/lib/browser';

export type ShowDebugBreakpointOptions = DebugSourceBreakpoint | {
position: monaco.Position,
Expand Down Expand Up @@ -69,6 +70,16 @@ export class DebugBreakpointWidget implements Disposable {
get input(): MonacoEditor | undefined {
return this._input;
}
// eslint-disable-next-line no-null/no-null
set inputSize(dimension: Dimension | null) {
if (this._input) {
if (dimension) {
this._input.setSize(dimension);
} else {
this._input.resizeToFit();
}
}
}

@postConstruct()
protected async init(): Promise<void> {
Expand Down
1 change: 1 addition & 0 deletions packages/debug/src/browser/editor/debug-editor-model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export class DebugEditorModel implements Disposable {
this.editor.getControl().onKeyDown(() => this.hover.hide({ immediate: false })),
this.editor.getControl().onDidChangeModelContent(() => this.update()),
this.editor.getControl().getModel()!.onDidChangeDecorations(() => this.updateBreakpoints()),
this.editor.onDidResize(e => this.breakpointWidget.inputSize = e),
this.sessions.onDidChange(() => this.update()),
this.toDisposeOnUpdate
]);
Expand Down
6 changes: 6 additions & 0 deletions packages/monaco/src/browser/monaco-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor {
readonly onLanguageChanged = this.onLanguageChangedEmitter.event;
protected readonly onScrollChangedEmitter = new Emitter<void>();
readonly onEncodingChanged = this.document.onDidChangeEncoding;
// eslint-disable-next-line no-null/no-null
protected readonly onResizeEmitter = new Emitter<Dimension | null>();
readonly onDidResize = this.onResizeEmitter.event;

readonly documents = new Set<MonacoEditorModel>();

Expand Down Expand Up @@ -340,10 +343,13 @@ export class MonacoEditor extends MonacoEditorServices implements TextEditor {

resizeToFit(): void {
this.autoresize();
// eslint-disable-next-line no-null/no-null
this.onResizeEmitter.fire(null);
}

setSize(dimension: Dimension): void {
this.resize(dimension);
this.onResizeEmitter.fire(dimension);
}

protected autoresize(): void {
Expand Down

0 comments on commit 64e613f

Please sign in to comment.