diff --git a/codetab.ts b/codetab.ts index 48650d3..d9556ac 100644 --- a/codetab.ts +++ b/codetab.ts @@ -230,7 +230,7 @@ const gridToIndex = (str: string, x: number, y: number) => { if (y >= lines.length) { return str.length; } - return lines.slice(0, y).join("\n").length+Math.min(x, lines[y].length)+1; + return lines.slice(0, y).join("\n").length+Math.min(x, lines[y].length)+(y === 0 ? 0 : 1); } const keywords = [