Skip to content
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

fix linkifier after shrinking #1769

Closed
wants to merge 23 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
c4db617
fix linkifier after shrinking
jerch Oct 25, 2018
93d51c6
Merge branch 'master' into fix_linkifier_after_shrinking
jerch Oct 25, 2018
cdc175d
fix test case docs
jerch Oct 25, 2018
e855af9
cleanup Linkifier.test.ts
jerch Oct 25, 2018
581d231
fix underline of last cell
jerch Oct 25, 2018
d5badcc
change cell content for enlarging resize
jerch Oct 25, 2018
1218c83
workaround for after enlarging
jerch Oct 26, 2018
136f2bd
revert empty cell changes, getTrimmedLength for Bufferline
jerch Oct 26, 2018
0be9873
remove remnant
jerch Oct 26, 2018
d1fcfd5
test cases, docs
jerch Oct 26, 2018
1c23b17
Merge branch 'master' into fix_linkifier_after_shrinking
Tyriar Oct 29, 2018
36375c6
workaround without empty cells
jerch Oct 30, 2018
b0e2e47
Merge branch 'fix_linkifier_after_shrinking' of git+ssh://github.com/…
jerch Oct 30, 2018
9bab881
Merge branch 'fix_linkifier_after_shrinking' of git+ssh://github.com/…
jerch Oct 30, 2018
8301068
Merge branch 'fix_linkifier_after_shrinking' of git+ssh://github.com/…
jerch Dec 15, 2018
1b17ce2
Merge branch 'master' into fix_linkifier_after_shrinking
jerch Dec 15, 2018
fff3337
fix tests
jerch Dec 16, 2018
ae905ec
remove readded stuff
jerch Dec 16, 2018
fb92452
reset cell behind early wrap
jerch Dec 16, 2018
c7fa89d
apply new trimming to linkifier
jerch Dec 16, 2018
b549add
Merge branch 'master' into fix_linkifier_after_shrinking
jerch Dec 17, 2018
635fc72
handle invalid string buffer indices
jerch Dec 17, 2018
f91dde8
add sanity check for visible length
jerch Dec 17, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
workaround without empty cells
jerch committed Oct 30, 2018

Verified

This commit was signed with the committer’s verified signature.
fengmk2 fengmk2
commit 36375c62a963f141dd948e01e4f6184de66bc671
3 changes: 2 additions & 1 deletion src/Buffer.ts
Original file line number Diff line number Diff line change
@@ -155,7 +155,8 @@ export class Buffer implements IBuffer {
if (this.lines.length > 0) {
// Deal with columns increasing (we don't do anything when columns reduce)
if (this._terminal.cols < newCols) {
const ch: CharData = [DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]; // does xterm use the default attr?
//const ch: CharData = [DEFAULT_ATTR, NULL_CELL_CHAR, NULL_CELL_WIDTH, NULL_CELL_CODE]; // does xterm use the default attr?
const ch: CharData = [DEFAULT_ATTR, '', 0, undefined];
for (let i = 0; i < this.lines.length; i++) {
this.lines.get(i).resize(newCols, ch);
}
3 changes: 3 additions & 0 deletions src/InputHandler.ts
Original file line number Diff line number Diff line change
@@ -390,6 +390,9 @@ export class InputHandler extends Disposable implements IInputHandler {
// autowrap - DECAWM
// automatically wraps to the beginning of the next line
if (wraparoundMode) {
for (let i = buffer.x; i < bufferRow.length; ++i) {
bufferRow.set(i, [curAttr, '', 0, undefined]);
}
buffer.x = 0;
buffer.y++;
if (buffer.y > buffer.scrollBottom) {
7 changes: 4 additions & 3 deletions src/Linkifier.ts
Original file line number Diff line number Diff line change
@@ -110,7 +110,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
// 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(
true, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
false, absoluteRowIndexStart, absoluteRowIndexEnd, overscanLineLimit, overscanLineLimit);
while (iterator.hasNext()) {
const lineData: IBufferStringIteratorResult = iterator.next();
for (let i = 0; i < this._linkMatchers.length; i++) {
@@ -220,12 +220,12 @@ export class Linkifier extends EventEmitter implements ILinkifier {
rex.lastIndex = stringIndex + uri.length;

// get the buffer index as [absolute row, col] for the match
const bufferIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex, true);
const bufferIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex, false);
// calculate buffer index of uri end
// we cannot directly use uri.length here since stringIndexToBufferIndex would
// skip empty cells and stop at the next cell with real content
// instead we fetch the index of the last char in uri and advance to the next cell
const endIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex + uri.length - 1, true);
const endIndex = this._terminal.buffer.stringIndexToBufferIndex(rowIndex, stringIndex + uri.length - 1, false);

// adjust start index to visible line length
if (bufferIndex[1] >= this._terminal.cols) {
@@ -245,6 +245,7 @@ export class Linkifier extends EventEmitter implements ILinkifier {
endIndex[1] = this._terminal.cols;
}
const visibleLength = (endIndex[0] - bufferIndex[0]) * this._terminal.cols - bufferIndex[1] + endIndex[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does using visibleLength mean URLs will be broken if the viewport is shrunk?

Copy link
Member Author

@jerch jerch Oct 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visibleLength is just there to give the marker the length to underline. This makes sure that the underline does not over- or underflow the real end of the URL. So after shrinking the underline should stick to chars that really belong to the URL. Side effect of this - after enlarging inserted empty cells are also underlined. To get rid of this, the underline marker would have to support multiple chunks to underline.

console.log(uri);

const line = this._terminal.buffer.lines.get(bufferIndex[0]);
const char = line.get(bufferIndex[1]);