fix: start endFoundIdx at -1

This commit is contained in:
Spencer Gouw 2023-09-22 22:14:57 -05:00
parent b769bf70be
commit 8cf68cfc87

View file

@ -21,7 +21,7 @@ export namespace Symbol {
const len = inputStr.length;
let i = 0;
let cursor = 0;
let endFoundIdx = 0;
let endFoundIdx = -1;
let hasNewline = false;
let found;
while (i < inputStr.length) {
@ -29,7 +29,6 @@ export namespace Symbol {
for (const symbol in REPLACEABLE) {
if (inputStr.startsWith(symbol, i)) {
result.push(REPLACEABLE[symbol]);
console.log(REPLACEABLE[symbol]);
cursor += REPLACEABLE[symbol].length;
i += symbol.length;
found = true;
@ -55,7 +54,7 @@ export namespace Symbol {
let data = result.join("");
let info = {
hasNewline,
cursorEnd: data.length - endFoundIdx,
cursorEnd: endFoundIdx < 0 ? 0 : data.length - endFoundIdx,
};
return { data, info };