Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8311c48

Browse files
Copilottsnobip
andcommitted
Fix error validation logic - properly validate both line and column bounds
Co-authored-by: tsnobip <2479216+tsnobip@users.noreply.github.com>
1 parentcc339b5 commit8311c48

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎src/components/CodeMirror.res‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,22 @@ let createEditor = %raw(`
191191
returnerrorsArray.map(err=> {
192192
try {
193193
constdoc=view.state.doc;
194-
// Validate line numbers (1-based to 0-based conversion)
194+
// Error row/endRow are 1-based (same as CodeMirror 5)
195+
// Validate line numbers are within document bounds
195196
constfromLine=Math.max(1,Math.min(err.row,doc.lines));
196197
consttoLine=Math.max(1,Math.min(err.endRow,doc.lines));
197198
199+
// Get line objects
200+
conststartLine=doc.line(fromLine);
201+
constendLine=doc.line(toLine);
202+
203+
// Validate column positions are within line bounds
204+
constfromCol=Math.max(0,Math.min(err.column,startLine.length));
205+
consttoCol=Math.max(0,Math.min(err.endColumn,endLine.length));
206+
198207
return {
199-
from:doc.line(fromLine).from+err.column,
200-
to:doc.line(toLine).from+err.endColumn,
208+
from:startLine.from+fromCol,
209+
to:endLine.from+toCol,
201210
severity:err.kind===0?"error":"warning",
202211
message:err.text
203212
};

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp