Skip to content

Commit a6cb7af

Browse files
committed
fix: #22
1 parent d82bde5 commit a6cb7af

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/main.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,13 @@ class AcodePrettier {
277277
endRow--;
278278
}
279279

280+
// Ensure endRow is within bounds
281+
endRow = Math.min(endRow, lines.length - 1);
282+
280283
// Store the actual selection range for replacement
281284
const selectionRange = {
282285
start: { row: startRow, column: 0 },
283-
end: { row: endRow, column: lines[endRow].length }
286+
end: { row: endRow, column: lines[endRow]?.length ?? 0 }
284287
};
285288

286289
// Extract the selected lines
@@ -407,10 +410,10 @@ class AcodePrettier {
407410
</div>`,
408411
});
409412
this.#sideButton?.show();
410-
this.#page.append($error);
413+
this.#page.prepend($error);
411414

412415
if (this.#page.childElementCount > 10) {
413-
this.#page.firstChild.remove();
416+
this.#page.lastChild.remove();
414417
}
415418

416419
if (this.prettierOptions.openErrorPageOnErrors) {

0 commit comments

Comments
 (0)