diff --git a/extraterm/src/render_process/TerminalCanvas.ts b/extraterm/src/render_process/TerminalCanvas.ts index 9620b7cd3..7af369a09 100644 --- a/extraterm/src/render_process/TerminalCanvas.ts +++ b/extraterm/src/render_process/TerminalCanvas.ts @@ -282,6 +282,10 @@ export class TerminalCanvas extends ThemeableElementBase implements AcceptsConfi private _handleBeforeSelectionChange(ev: CustomEvent): void { const target = ev.target; + if (this._mode === Mode.DEFAULT && ! ( target).hasSelection()) { + return; + } + this._childElementList.forEach( (nodeInfo): void => { const node = nodeInfo.element; if (node !== target) { diff --git a/extraterm/src/render_process/viewers/EmbeddedViewer.ts b/extraterm/src/render_process/viewers/EmbeddedViewer.ts index e6a0edf04..2559da4a0 100644 --- a/extraterm/src/render_process/viewers/EmbeddedViewer.ts +++ b/extraterm/src/render_process/viewers/EmbeddedViewer.ts @@ -379,6 +379,11 @@ export class EmbeddedViewer extends ViewerElement implements SupportsClipboardPa const viewerElement = this.getViewerElement(); return viewerElement === null ? null : viewerElement.getSelectionText(); } + + hasSelection(): boolean { + const viewerElement = this.getViewerElement(); + return viewerElement === null ? false : viewerElement.hasSelection(); + } getBulkFileHandle(): BulkFileHandle { const viewerElement = this.getViewerElement(); diff --git a/extraterm/src/render_process/viewers/TerminalAceViewer.ts b/extraterm/src/render_process/viewers/TerminalAceViewer.ts index e50800e91..f42492cb7 100644 --- a/extraterm/src/render_process/viewers/TerminalAceViewer.ts +++ b/extraterm/src/render_process/viewers/TerminalAceViewer.ts @@ -410,11 +410,11 @@ export class TerminalViewer extends ViewerElement implements SupportsClipboardPa } getSelectionText(): string { - if (this._aceEditor.selection.isEmpty()) { + const selection = this._aceEditSession.getSelection() + if (selection.isEmpty()) { return null; } - const selection = this._aceEditSession.getSelection() if (selection.inMultiSelectMode) { return selection.getAllRanges().map(range => this._aceEditSession.getUnwrappedTextRange(range)).join("\n"); } else { diff --git a/extraterm/src/render_process/viewers/ViewerElement.ts b/extraterm/src/render_process/viewers/ViewerElement.ts index 92ab5cbf6..a073a7b4f 100644 --- a/extraterm/src/render_process/viewers/ViewerElement.ts +++ b/extraterm/src/render_process/viewers/ViewerElement.ts @@ -49,7 +49,11 @@ export abstract class ViewerElement extends ThemeableElementBase implements Virt getSelectionText(): string { return null; } - + + hasSelection(): boolean { + return false; + } + clearSelection(): void { }