-
Notifications
You must be signed in to change notification settings - Fork 1.8k
fix overscan issue and enable linkifier on partial shown matches #1693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
d0dc387
fix overscan issue and enable linkify of partial shown matches
jerch 842ee6c
change overscan limit to 2k chars
jerch 5284a5a
fix spelling
jerch 1108d07
Merge branch 'master' into fix_1691
jerch 10687b1
range checks for buffer iterator
jerch a30bb22
fix comments to <80
jerch 408403e
Merge branch 'master' into fix_1691
jerch 57a6fe5
Merge branch 'master' into fix_1691
jerch fefc6c6
fix typo
jerch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,6 +21,13 @@ export class Linkifier extends EventEmitter implements ILinkifier { | |
| */ | ||
| protected static readonly TIME_BEFORE_LINKIFY = 200; | ||
|
|
||
| /** | ||
| * Limit of the unwrapping line expansion (overscan) at the top and bottom | ||
| * of the actual viewport in ASCII characters. | ||
| * A limit of 2000 should match most sane urls. | ||
| */ | ||
| protected static readonly OVERSCAN_CHAR_LIMIT = 2000; | ||
|
|
||
| protected _linkMatchers: ILinkMatcher[] = []; | ||
|
|
||
| private _mouseZoneManager: IMouseZoneManager; | ||
|
|
@@ -92,11 +99,19 @@ export class Linkifier extends EventEmitter implements ILinkifier { | |
| // Invalidate bad end row values (if a resize happened) | ||
| const absoluteRowIndexEnd = buffer.ydisp + Math.min(this._rowsToLinkify.end, this._terminal.rows) + 1; | ||
|
|
||
| // iterate over the range of unwrapped content strings within start..end (excluding) | ||
| // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset for every matcher | ||
| // for wrapped content over several rows the iterator might return rows outside the viewport | ||
| // we skip those later in _doLinkifyRow | ||
| const iterator = buffer.iterator(false, absoluteRowIndexStart, absoluteRowIndexEnd); | ||
| // Iterate over the range of unwrapped content strings within start..end | ||
| // (excluding). | ||
| // _doLinkifyRow gets full unwrapped lines with the start row as buffer offset | ||
| // for every matcher. | ||
| // The unwrapping is needed to also match content that got wrapped across | ||
| // several buffer lines. To avoid a worst case szenario where the whole buffer | ||
|
||
| // contains just a single unwrapped string we limit this line expansion beyond | ||
| // the viewport to +OVERSCAN_CHAR_LIMIT chars (overscan) at top and bottom. | ||
| // This comes with the tradeoff that matches longer than OVERSCAN_CHAR_LIMIT | ||
| // chars will not match anymore at the viewport borders. | ||
| const overscanLineLimit = Math.ceil(Linkifier.OVERSCAN_CHAR_LIMIT / this._terminal.cols); | ||
| const iterator = this._terminal.buffer.iterator( | ||
| false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit); | ||
| while (iterator.hasNext()) { | ||
| const lineData: IBufferStringIteratorResult = iterator.next(); | ||
| for (let i = 0; i < this._linkMatchers.length; i++) { | ||
|
|
@@ -208,14 +223,6 @@ export class Linkifier extends EventEmitter implements ILinkifier { | |
| // get the buffer index as [absolute row, col] for the match | ||
| const bufferIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex); | ||
|
|
||
| // skip rows outside of the viewport | ||
| if (bufferIndex[0] - this._terminal.buffer.ydisp < 0) { | ||
| continue; | ||
| } | ||
| if (bufferIndex[0] - this._terminal.buffer.ydisp > this._terminal.rows) { | ||
| break; | ||
| } | ||
|
|
||
| const line = this._terminal.buffer.lines.get(bufferIndex[0]); | ||
| const char = line.get(bufferIndex[1]); | ||
| let fg: number | undefined; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.