(position: IBufferCellPosition, useLineCache: boolean)
| 106 | } |
| 107 | |
| 108 | private _askForLink(position: IBufferCellPosition, useLineCache: boolean): void { |
| 109 | if (!this._activeProviderReplies || !useLineCache) { |
| 110 | this._activeProviderReplies?.forEach(reply => { |
| 111 | reply?.forEach(linkWithState => { |
| 112 | if (linkWithState.link.dispose) { |
| 113 | linkWithState.link.dispose(); |
| 114 | } |
| 115 | }); |
| 116 | }); |
| 117 | this._activeProviderReplies = new Map(); |
| 118 | this._activeLine = position.y; |
| 119 | } |
| 120 | let linkProvided = false; |
| 121 | |
| 122 | // There is no link cached, so ask for one |
| 123 | for (const [i, linkProvider] of this._linkProviderService.linkProviders.entries()) { |
| 124 | if (useLineCache) { |
| 125 | const existingReply = this._activeProviderReplies?.get(i); |
| 126 | // If there isn't a reply, the provider hasn't responded yet. |
| 127 | |
| 128 | // TODO: If there isn't a reply yet it means that the provider is still resolving. Ensuring |
| 129 | // provideLinks isn't triggered again saves ILink.hover firing twice though. This probably |
| 130 | // needs promises to get fixed |
| 131 | if (existingReply) { |
| 132 | linkProvided = this._checkLinkProviderResult(i, position, linkProvided); |
| 133 | } |
| 134 | } else { |
| 135 | linkProvider.provideLinks(position.y, (links: ILink[] | undefined) => { |
| 136 | if (this._isMouseOut) { |
| 137 | return; |
| 138 | } |
| 139 | const linksWithState: ILinkWithState[] | undefined = links?.map(link => ({ link })); |
| 140 | this._activeProviderReplies?.set(i, linksWithState); |
| 141 | linkProvided = this._checkLinkProviderResult(i, position, linkProvided); |
| 142 | |
| 143 | // If all providers have responded, remove lower priority links that intersect ranges of |
| 144 | // higher priority links |
| 145 | if (this._activeProviderReplies?.size === this._linkProviderService.linkProviders.length) { |
| 146 | this._removeIntersectingLinks(position.y, this._activeProviderReplies); |
| 147 | } |
| 148 | }); |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | private _removeIntersectingLinks(y: number, replies: Map<Number, ILinkWithState[] | undefined>): void { |
| 154 | const occupiedCells = new Set<number>(); |
no test coverage detected