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 #948 #1108

Merged
merged 2 commits into from
Nov 6, 2017
Merged

Fix #948 #1108

merged 2 commits into from
Nov 6, 2017

Conversation

bmf-ribeiro
Copy link
Contributor

Fix suggested in #948

This is my first pull request, so all feedback is welcome.

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

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

Welcome 😄 I have a few comments

src/Buffer.ts Outdated
@@ -11,6 +11,7 @@ export const CHAR_DATA_ATTR_INDEX = 0;
export const CHAR_DATA_CHAR_INDEX = 1;
export const CHAR_DATA_WIDTH_INDEX = 2;
export const CHAR_DATA_CODE_INDEX = 3;
export const MAX_BUFFER_SIZE = -1 >>> 0; // 2^32 - 1
Copy link
Member

Choose a reason for hiding this comment

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

Are you sure this works consistently across all browsers? Doing an unsigned bit operation on a signed number seems dangerous. Might be better to just stick the number in there.

src/Buffer.ts Outdated
@@ -68,7 +69,10 @@ export class Buffer implements IBuffer {
if (!this._hasScrollback) {
return rows;
}
return rows + this._terminal.options.scrollback;

const correctBuferLength = rows + this._terminal.options.scrollback;
Copy link
Member

Choose a reason for hiding this comment

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

correctBuferLengthcorrectBufferLength

Also, is this here only to cover the case where scrollback is set from the Terminal constructor? If so it might be good to validate at in the Terminal constructor instead of every time _getCorrectBufferLength is requested

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When i first bumped into this was via terminal.setOption(), and if my understanding is correct we could also trigger this by resizing the terminal, and increasing the number of rows if the buffer size was MAX_BUFFER_SIZE.

src/Terminal.ts Outdated
@@ -384,6 +384,8 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
}
break;
case 'scrollback':
value = value > 0 && value <= MAX_BUFFER_SIZE ? value : MAX_BUFFER_SIZE;
Copy link
Member

Choose a reason for hiding this comment

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

Math.min would be preferable to this ternary, I was surprised how fast it was when I looked into it.

@Tyriar Tyriar self-assigned this Nov 6, 2017
@Tyriar Tyriar added this to the 3.0.0 milestone Nov 6, 2017
@Tyriar
Copy link
Member

Tyriar commented Nov 6, 2017

Thanks for the contribution and quick follow up 🎉

@Tyriar Tyriar merged commit 0637191 into xtermjs:v3 Nov 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants