Fix issues with link state

- Scrolling will now clear the link renderer
- Refreshing a single line will now recalculate only that line

Fixes #959
Fixes #960
This commit is contained in:
Daniel Imms
2017-09-09 19:06:30 -07:00
parent 948eedba89
commit 0e3518409e
4 changed files with 52 additions and 14 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
export interface IMouseZoneManager {
add(zone: IMouseZone): void;
clearAll(): void;
clearAll(start?: number, end?: number): void;
}
export interface IMouseZone {
+22 -3
View File
@@ -44,9 +44,28 @@ export class MouseZoneManager implements IMouseZoneManager {
}
}
public clearAll(): void {
this._zones.length = 0;
this._deactivate();
public clearAll(start?: number, end?: number): void {
// Exit if there's nothing to clear
if (this._zones.length === 0) {
return;
}
// Iterate through zones and clear them out if they're within the range
for (let i = 0; i < this._zones.length; i++) {
const zone = this._zones[i];
if (zone.y >= start && zone.y <= end) {
if (this._currentZone && this._currentZone === zone) {
this._currentZone.leaveCallback();
this._currentZone = null;
}
this._zones.splice(i--, 1);
}
}
// Deactivate the mouse zone manager if all the zones have been removed
if (this._zones.length === 0) {
this._deactivate();
}
}
private _activate(): void {