Skip to content

Commit

Permalink
sash: workbench.sash.hoverDelay setting
Browse files Browse the repository at this point in the history
fixes #118158
  • Loading branch information
joaomoreno committed Mar 11, 2021
1 parent 10fc457 commit 244428d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 7 deletions.
14 changes: 12 additions & 2 deletions src/vs/base/browser/ui/sash/sash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,22 @@ export function setGlobalSashSize(size: number): void {
onDidChangeGlobalSize.fire(size);
}

let globalHoverDelay = 300;
const onDidChangeHoverDelay = new Emitter<number>();
export function setGlobalHoverDelay(size: number): void {
globalHoverDelay = size;
onDidChangeHoverDelay.fire(size);
}

export class Sash extends Disposable {

private el: HTMLElement;
private layoutProvider: ISashLayoutProvider;
private hidden: boolean;
private orientation!: Orientation;
private size: number;
private hoverDelayer = this._register(new Delayer(300));
private hoverDelay = globalHoverDelay;
private hoverDelayer = this._register(new Delayer(this.hoverDelay));

private _state: SashState = SashState.Enabled;
get state(): SashState { return this._state; }
Expand Down Expand Up @@ -221,6 +229,8 @@ export class Sash extends Disposable {
}));
}

this._register(onDidChangeHoverDelay.event(delay => this.hoverDelay = delay));

this.hidden = false;
this.layoutProvider = layoutProvider;

Expand Down Expand Up @@ -403,7 +413,7 @@ export class Sash extends Disposable {
sash.hoverDelayer.cancel();
sash.el.classList.add('hover');
} else {
sash.hoverDelayer.trigger(() => sash.el.classList.add('hover')).then(undefined, () => { });
sash.hoverDelayer.trigger(() => sash.el.classList.add('hover'), sash.hoverDelay).then(undefined, () => { });
}

if (!fromLinkedSash && sash.linkedSash) {
Expand Down
7 changes: 7 additions & 0 deletions src/vs/workbench/contrib/sash/browser/sash.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
maximum: maxSize,
description: localize('sashSize', "Controls the feedback area size in pixels of the dragging area in between views/editors. Set it to a larger value if you feel it's hard to resize views using the mouse.")
},
'workbench.sash.hoverDelay': {
type: 'number',
default: 300,
minimum: 0,
maximum: 2000,
description: localize('sashHoverDelay', "Controls the hover feedback delay in milliseconds of the dragging area in between views/editors.")
},
}
});

Expand Down
18 changes: 13 additions & 5 deletions src/vs/workbench/contrib/sash/browser/sash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { clamp } from 'vs/base/common/numbers';
import { setGlobalSashSize } from 'vs/base/browser/ui/sash/sash';
import { setGlobalSashSize, setGlobalHoverDelay } from 'vs/base/browser/ui/sash/sash';
import { Event } from 'vs/base/common/event';
import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
Expand All @@ -20,17 +20,25 @@ export class SashSettingsController implements IWorkbenchContribution, IDisposab
constructor(
@IConfigurationService private readonly configurationService: IConfigurationService
) {
const onDidChangeSizeConfiguration = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('workbench.sash.size'));
onDidChangeSizeConfiguration(this.onDidChangeSizeConfiguration, this, this.disposables);
this.onDidChangeSizeConfiguration();
const onDidChangeSize = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('workbench.sash.size'));
onDidChangeSize(this.onDidChangeSize, this, this.disposables);
this.onDidChangeSize();

const onDidChangeHoverDelay = Event.filter(configurationService.onDidChangeConfiguration, e => e.affectsConfiguration('workbench.sash.hoverDelay'));
onDidChangeHoverDelay(this.onDidChangeHoverDelay, this, this.disposables);
this.onDidChangeHoverDelay();
}

private onDidChangeSizeConfiguration(): void {
private onDidChangeSize(): void {
const size = clamp(this.configurationService.getValue<number>('workbench.sash.size') ?? minSize, minSize, maxSize);
document.documentElement.style.setProperty('--sash-size', size + 'px');
setGlobalSashSize(size);
}

private onDidChangeHoverDelay(): void {
setGlobalHoverDelay(this.configurationService.getValue<number>('workbench.sash.hoverDelay'));
}

dispose(): void {
this.disposables.dispose();
}
Expand Down

0 comments on commit 244428d

Please sign in to comment.