Support multiline links in the WebLinksAddon

This commit is contained in:
Jon Bockhorst
2019-11-05 23:35:20 -06:00
parent b3d95d20dc
commit ac6c8a5bd3
3 changed files with 70 additions and 14 deletions
+10 -2
View File
@@ -8,6 +8,7 @@ import { IDisposable } from 'common/Types';
import { IMouseService } from './services/Services';
import { IBufferService, ICoreService } from 'common/services/Services';
import { EventEmitter, IEvent } from 'common/EventEmitter';
import { LinkRenderLayer } from './renderer/LinkRenderLayer';
export class Linkifier2 implements ILinkifier2 {
private _element: HTMLElement | undefined;
@@ -206,9 +207,16 @@ export class Linkifier2 implements ILinkifier2 {
* @param position
*/
private _linkAtPosition(link: ILink, position: IBufferCellPosition): boolean {
return link.range.start.x <= position.x &&
const sameLine = link.range.start.y === link.range.end.y;
const wrappedFromLeft = link.range.start.y < position.y;
const wrappedToRight = link.range.end.y > position.y;
// If the start and end have the same y, then the position must be between start and end x
// If not, then handle each case seperately, depending on which way it wraps
return ((sameLine && link.range.start.x <= position.x && link.range.end.x >= position.x) ||
(wrappedFromLeft && link.range.end.x >= position.x) ||
(wrappedToRight && link.range.start.x <= position.x)) &&
link.range.start.y <= position.y &&
link.range.end.x >= position.x &&
link.range.end.y >= position.y;
}