Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Imms <[email protected]>
  • Loading branch information
marvinthepa and Tyriar authored Feb 2, 2021
1 parent 6982201 commit 5a965b1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions addons/xterm-addon-web-links/src/WebLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ export class WebLinkProvider implements ILinkProvider {

public provideLinks(y: number, callback: (links: ILink[] | undefined) => void): void {
const links = LinkComputer.computeLink(y, this._regex, this._terminal, this._handler);
callback(this._addCallBacks(links, this._options.tooltipCallback, this._options.leaveCallback));
callback(this._addCallbacks(links, this._options.tooltipCallback, this._options.leaveCallback));
}

private _addCallBacks(links: ILink[], hover?: (event: MouseEvent, uri: string, location: IViewportRange) => void, leave?: (event: MouseEvent, uri: string) => void): ILink[] {
return links.map((link): ILink => {
private _addCallbacks(links: ILink[], hover?: (event: MouseEvent, uri: string, location: IViewportRange) => void, leave?: (event: MouseEvent, uri: string) => void): ILink[] {
return links.map(link => {
let hoverCallback = (event: MouseEvent, uri: string): void => { };
if (hover) {
hoverCallback = (event, uri): void => {
const { range } = link;
hover(event, uri, range);
};
}
return { ...link, leave, hover: hoverCallback };
link.leave = leave;
link.hover = hoverCallback;
return link;
});
}
}
Expand Down

0 comments on commit 5a965b1

Please sign in to comment.