Skip to content

Commit

Permalink
Be more careful about when to clear the selection
Browse files Browse the repository at this point in the history
issue #243
  • Loading branch information
sedwards2009 committed Feb 5, 2020
1 parent 842ca1a commit e7247db
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions extraterm/src/render_process/TerminalCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 && ! (<ViewerElement> target).hasSelection()) {
return;
}

this._childElementList.forEach( (nodeInfo): void => {
const node = nodeInfo.element;
if (node !== target) {
Expand Down
5 changes: 5 additions & 0 deletions extraterm/src/render_process/viewers/EmbeddedViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions extraterm/src/render_process/viewers/TerminalAceViewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 5 additions & 1 deletion extraterm/src/render_process/viewers/ViewerElement.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,11 @@ export abstract class ViewerElement extends ThemeableElementBase implements Virt
getSelectionText(): string {
return null;
}


hasSelection(): boolean {
return false;
}

clearSelection(): void {
}

Expand Down

0 comments on commit e7247db

Please sign in to comment.