(str)
| 1176 | |
| 1177 | // Returns the last character's display position of the given string |
| 1178 | [kGetDisplayPos](str) { |
| 1179 | let offset = 0; |
| 1180 | const col = this.columns; |
| 1181 | let rows = 0; |
| 1182 | str = stripVTControlCharacters(str); |
| 1183 | |
| 1184 | for (const char of new SafeStringIterator(str)) { |
| 1185 | if (char === '\n') { |
| 1186 | // Rows must be incremented by 1 even if offset = 0 or col = +Infinity. |
| 1187 | rows += MathCeil(offset / col) || 1; |
| 1188 | // Only add prefix offset for continuation lines in user input (not prompts) |
| 1189 | offset = this[kIsMultiline] ? kMultilinePrompt.description.length : 0; |
| 1190 | continue; |
| 1191 | } |
| 1192 | // Tabs must be aligned by an offset of the tab size. |
| 1193 | if (char === '\t') { |
| 1194 | offset += this.tabSize - (offset % this.tabSize); |
| 1195 | continue; |
| 1196 | } |
| 1197 | const width = getStringWidth(char, false /* stripVTControlCharacters */); |
| 1198 | if (width === 0 || width === 1) { |
| 1199 | offset += width; |
| 1200 | } else { |
| 1201 | // width === 2 |
| 1202 | if ((offset + 1) % col === 0) { |
| 1203 | offset++; |
| 1204 | } |
| 1205 | offset += 2; |
| 1206 | } |
| 1207 | } |
| 1208 | |
| 1209 | const cols = offset % col; |
| 1210 | rows += (offset - cols) / col; |
| 1211 | |
| 1212 | return { cols, rows }; |
| 1213 | } |
| 1214 | |
| 1215 | /** |
| 1216 | * Returns the real position of the cursor in relation |
nothing calls this directly
no test coverage detected