Merge pull request #5423 from Tyriar/tyriar/resize5300
Clear selection on vertical resize
This commit is contained in:
@@ -152,6 +152,14 @@ export class SelectionService extends Disposable implements ISelectionService {
|
|||||||
this._register(toDisposable(() => {
|
this._register(toDisposable(() => {
|
||||||
this._removeMouseDownListeners();
|
this._removeMouseDownListeners();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// Clear selection when resizing vertically. This experience could be improved, this is the
|
||||||
|
// simple option to fix the buggy behavior. https://github.com/xtermjs/xterm.js/issues/5300
|
||||||
|
this._register(this._bufferService.onResize(e => {
|
||||||
|
if (e.rowsChanged) {
|
||||||
|
this.clearSelection();
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
public reset(): void {
|
public reset(): void {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
* @license MIT
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, ICoreMouseService, ICharsetService, UnicodeCharProperties, UnicodeCharWidth, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum, IDecorationService, IInternalDecoration, IOscLinkService } from 'common/services/Services';
|
import { IBufferService, ICoreService, ILogService, IOptionsService, ITerminalOptions, ICoreMouseService, ICharsetService, UnicodeCharProperties, UnicodeCharWidth, IUnicodeService, IUnicodeVersionProvider, LogLevelEnum, IDecorationService, IInternalDecoration, IOscLinkService, type IBufferResizeEvent } from 'common/services/Services';
|
||||||
import { UnicodeService } from 'common/services/UnicodeService';
|
import { UnicodeService } from 'common/services/UnicodeService';
|
||||||
import { clone } from 'common/Clone';
|
import { clone } from 'common/Clone';
|
||||||
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
import { DEFAULT_OPTIONS } from 'common/services/OptionsService';
|
||||||
@@ -18,7 +18,7 @@ export class MockBufferService implements IBufferService {
|
|||||||
public serviceBrand: any;
|
public serviceBrand: any;
|
||||||
public get buffer(): IBuffer { return this.buffers.active; }
|
public get buffer(): IBuffer { return this.buffers.active; }
|
||||||
public buffers: IBufferSet = {} as any;
|
public buffers: IBufferSet = {} as any;
|
||||||
public onResize: Event<{ cols: number, rows: number }> = new Emitter<{ cols: number, rows: number }>().event;
|
public onResize: Event<IBufferResizeEvent> = new Emitter<IBufferResizeEvent>().event;
|
||||||
public onScroll: Event<number> = new Emitter<number>().event;
|
public onScroll: Event<number> = new Emitter<number>().event;
|
||||||
private readonly _onScroll = new Emitter<number>();
|
private readonly _onScroll = new Emitter<number>();
|
||||||
public isUserScrolling: boolean = false;
|
public isUserScrolling: boolean = false;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
|||||||
import { IAttributeData, IBufferLine } from 'common/Types';
|
import { IAttributeData, IBufferLine } from 'common/Types';
|
||||||
import { BufferSet } from 'common/buffer/BufferSet';
|
import { BufferSet } from 'common/buffer/BufferSet';
|
||||||
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
import { IBuffer, IBufferSet } from 'common/buffer/Types';
|
||||||
import { IBufferService, IOptionsService } from 'common/services/Services';
|
import { IBufferService, IOptionsService, type IBufferResizeEvent } from 'common/services/Services';
|
||||||
import { Emitter } from 'vs/base/common/event';
|
import { Emitter } from 'vs/base/common/event';
|
||||||
|
|
||||||
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
|
export const MINIMUM_COLS = 2; // Less than 2 can mess with wide chars
|
||||||
@@ -22,7 +22,7 @@ export class BufferService extends Disposable implements IBufferService {
|
|||||||
/** Whether the user is scrolling (locks the scroll position) */
|
/** Whether the user is scrolling (locks the scroll position) */
|
||||||
public isUserScrolling: boolean = false;
|
public isUserScrolling: boolean = false;
|
||||||
|
|
||||||
private readonly _onResize = this._register(new Emitter<{ cols: number, rows: number }>());
|
private readonly _onResize = this._register(new Emitter<IBufferResizeEvent>());
|
||||||
public readonly onResize = this._onResize.event;
|
public readonly onResize = this._onResize.event;
|
||||||
private readonly _onScroll = this._register(new Emitter<number>());
|
private readonly _onScroll = this._register(new Emitter<number>());
|
||||||
public readonly onScroll = this._onScroll.event;
|
public readonly onScroll = this._onScroll.event;
|
||||||
@@ -43,12 +43,12 @@ export class BufferService extends Disposable implements IBufferService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public resize(cols: number, rows: number): void {
|
public resize(cols: number, rows: number): void {
|
||||||
|
const colsChanged = this.cols !== cols;
|
||||||
|
const rowsChanged = this.rows !== rows;
|
||||||
this.cols = cols;
|
this.cols = cols;
|
||||||
this.rows = rows;
|
this.rows = rows;
|
||||||
this.buffers.resize(cols, rows);
|
this.buffers.resize(cols, rows);
|
||||||
// TODO: This doesn't fire when scrollback changes - add a resize event to BufferSet and forward
|
this._onResize.fire({ cols, rows, colsChanged, rowsChanged });
|
||||||
// event
|
|
||||||
this._onResize.fire({ cols, rows });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public reset(): void {
|
public reset(): void {
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export interface IBufferService {
|
|||||||
readonly buffer: IBuffer;
|
readonly buffer: IBuffer;
|
||||||
readonly buffers: IBufferSet;
|
readonly buffers: IBufferSet;
|
||||||
isUserScrolling: boolean;
|
isUserScrolling: boolean;
|
||||||
onResize: Event<{ cols: number, rows: number }>;
|
onResize: Event<IBufferResizeEvent>;
|
||||||
onScroll: Event<number>;
|
onScroll: Event<number>;
|
||||||
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
|
scroll(eraseAttr: IAttributeData, isWrapped?: boolean): void;
|
||||||
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
|
scrollLines(disp: number, suppressScrollEvent?: boolean): void;
|
||||||
@@ -26,6 +26,13 @@ export interface IBufferService {
|
|||||||
reset(): void;
|
reset(): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IBufferResizeEvent {
|
||||||
|
cols: number;
|
||||||
|
rows: number;
|
||||||
|
colsChanged: boolean;
|
||||||
|
rowsChanged: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
export const ICoreMouseService = createDecorator<ICoreMouseService>('CoreMouseService');
|
export const ICoreMouseService = createDecorator<ICoreMouseService>('CoreMouseService');
|
||||||
export interface ICoreMouseService {
|
export interface ICoreMouseService {
|
||||||
serviceBrand: undefined;
|
serviceBrand: undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user