| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 09ca8be commit 92dcf3e
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -720,16 +720,16 @@ Interface.prototype._historyPrev = function() { | |||
| 720 | 720 | Interface.prototype._getDisplayPos = function(str) { | |
| 721 | 721 | let offset = 0; | |
| 722 | 722 | const col = this.columns; | |
| 723 | - let row = 0; | ||
| 723 | + let rows = 0; | ||
| 724 | 724 | str = stripVTControlCharacters(str); | |
| 725 | 725 | for (let i = 0, len = str.length; i < len; i++) { | |
| 726 | 726 | const code = str.codePointAt(i); | |
| 727 | 727 | if (code >= kUTF16SurrogateThreshold) { // Surrogates. | |
| 728 | 728 | i++; | |
| 729 | 729 | } | |
| 730 | 730 | if (code === 0x0a) { // new line \n | |
| 731 | - // row must be incremented by 1 even if offset = 0 or col = +Infinity | ||
| 732 | - row += MathCeil(offset / col) || 1; | ||
| 731 | + // rows must be incremented by 1 even if offset = 0 or col = +Infinity | ||
| 732 | + rows += MathCeil(offset / col) || 1; | ||
| 733 | 733 | offset = 0; | |
| 734 | 734 | continue; | |
| 735 | 735 | } | |
@@ -744,17 +744,16 @@ Interface.prototype._getDisplayPos = function(str) { | |||
| 744 | 744 | } | |
| 745 | 745 | } | |
| 746 | 746 | const cols = offset % col; | |
| 747 | - const rows = row + (offset - cols) / col; | ||
| 748 | - return { cols: cols, rows: rows }; | ||
| 747 | + rows += (offset - cols) / col; | ||
| 748 | + return { cols, rows }; | ||
| 749 | 749 | }; | |
| 750 | 750 | ||
| 751 | 751 | ||
| 752 | 752 | // Returns current cursor's position and line | |
| 753 | 753 | Interface.prototype.getCursorPos = function() { | |
| 754 | 754 | const columns = this.columns; | |
| 755 | 755 | const strBeforeCursor = this._prompt + this.line.substring(0, this.cursor); | |
| 756 | - const dispPos = this._getDisplayPos( | ||
| 757 | - stripVTControlCharacters(strBeforeCursor)); | ||
| 756 | + const dispPos = this._getDisplayPos(strBeforeCursor); | ||
| 758 | 757 | let cols = dispPos.cols; | |
| 759 | 758 | let rows = dispPos.rows; | |
| 760 | 759 | // If the cursor is on a full-width character which steps over the line, | |
@@ -765,7 +764,7 @@ Interface.prototype.getCursorPos = function() { | |||
| 765 | 764 | rows++; | |
| 766 | 765 | cols = 0; | |
| 767 | 766 | } | |
| 768 | - return { cols: cols, rows: rows }; | ||
| 767 | + return { cols, rows }; | ||
| 769 | 768 | }; | |
| 770 | 769 | Interface.prototype._getCursorPos = Interface.prototype.getCursorPos; | |
| 771 | 770 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments