Skip to content

Commit

Permalink
Code cleanup and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yury committed Feb 8, 2018
1 parent cbe085e commit 8dec61e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 18 deletions.
9 changes: 9 additions & 0 deletions Resources/hterm_all.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ function setNodeText(node, text, opt_wcwidth) {
node.textContent = text;

if (node.nodeType === Node.TEXT_NODE) {

var parent = node.parentNode;
var next = node.nextSibling;

if (parent) {
parent.removeChild(node);
parent[next ? "insertBefore":"appendChild"](node, next);
}

return;
}

Expand Down
3 changes: 2 additions & 1 deletion Resources/hterm_all.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 12 additions & 17 deletions Resources/hterm_all.patches.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ hterm.Screen.prototype.deleteChars = function(count) {
var node = this.cursorNode_;
var offset = this.cursorOffset_;

var currentCursorColumn = this.cursorPosition.column;
count = Math.min(count, this.columnCount_ - currentCursorColumn);
if (!count) return 0;
// var currentCursorColumn = this.cursorPosition.column;
// count = Math.min(count, this.columnCount_ - currentCursorColumn);
// if (!count) return 0;

var rv = count;
var startLength, endLength;
Expand Down Expand Up @@ -410,21 +410,16 @@ hterm.Screen.prototype.overwriteString = function(str, wcwidth = undefined) {
this.cursorPosition.column += wcwidth;
return;
}


var node = this.cursorRowNode_;
var parent = this.cursorRowNode_.parentNode;
var next = this.cursorRowNode_.nextSibling

if (parent) {
parent.removeChild(node);
}

this.deleteChars(Math.min(wcwidth, maxLength));
this.insertString(str, wcwidth);

if (parent) {
parent[next ? "insertBefore":"append"](node, next);
// Blink optimization: Nothing to delete, just insert
if (this.cursorOffset_ === 0 &&
this.cursorPosition.column === 0 &&
this.cursorRowNode_.textContent.length === 0) {
this.insertString(str, wcwidth);
} else {
// Blink optimization: if we insert first. It is more likly we will match text
this.insertString(str, wcwidth);
this.deleteChars(wcwidth);
}
};

Expand Down

0 comments on commit 8dec61e

Please sign in to comment.