Skip to content

Commit 98bcd5f

Browse files
committed
fix(lsp): incorrect quick fix offset in vue files (#10742)
fixes #10540
1 parent f6f1c5c commit 98bcd5f

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

crates/oxc_language_server/src/snapshots/[email protected]

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ related_information[0].location.range: Range { start: Position { line: 1, charac
1212
severity: Some(Warning)
1313
source: Some("oxc")
1414
tags: None
15-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 0, character: 1 }, end: Position { line: 1, character: 5 } } })
15+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 1, character: 0 }, end: Position { line: 1, character: 8 } } })
1616

1717

1818
code: "eslint(no-debugger)"
@@ -25,7 +25,7 @@ related_information[0].location.range: Range { start: Position { line: 10, chara
2525
severity: Some(Warning)
2626
source: Some("oxc")
2727
tags: None
28-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 0, character: 3 }, end: Position { line: 1, character: 7 } } })
28+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 10, character: 2 }, end: Position { line: 10, character: 10 } } })
2929

3030

3131
code: "eslint(no-debugger)"
@@ -38,7 +38,7 @@ related_information[0].location.range: Range { start: Position { line: 14, chara
3838
severity: Some(Warning)
3939
source: Some("oxc")
4040
tags: None
41-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 0, character: 3 }, end: Position { line: 1, character: 7 } } })
41+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 14, character: 2 }, end: Position { line: 14, character: 10 } } })
4242

4343

4444
code: "eslint(no-debugger)"
@@ -51,4 +51,4 @@ related_information[0].location.range: Range { start: Position { line: 18, chara
5151
severity: Some(Warning)
5252
source: Some("oxc")
5353
tags: None
54-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 0, character: 3 }, end: Position { line: 1, character: 7 } } })
54+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 18, character: 2 }, end: Position { line: 18, character: 10 } } })

crates/oxc_language_server/src/snapshots/[email protected]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ related_information[0].location.range: Range { start: Position { line: 1, charac
1212
severity: Some(Warning)
1313
source: Some("oxc")
1414
tags: None
15-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 0, character: 2 }, end: Position { line: 1, character: 2 } } })
15+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 1, character: 1 }, end: Position { line: 1, character: 10 } } })

crates/oxc_language_server/src/snapshots/[email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ related_information[0].location.range: Range { start: Position { line: 5, charac
1212
severity: Some(Warning)
1313
source: Some("oxc")
1414
tags: None
15-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 0, character: 5 }, end: Position { line: 1, character: 2 } } })
15+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 5, character: 4 }, end: Position { line: 5, character: 12 } } })
1616

1717

1818
code: "eslint(no-debugger)"
@@ -25,4 +25,4 @@ related_information[0].location.range: Range { start: Position { line: 10, chara
2525
severity: Some(Warning)
2626
source: Some("oxc")
2727
tags: None
28-
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 2, character: 1 }, end: Position { line: 2, character: 10 } } })
28+
fixed: Some(FixedContent { message: Some("Remove the debugger statement"), code: "", range: Range { start: Position { line: 10, character: 4 }, end: Position { line: 10, character: 13 } } })

crates/oxc_linter/src/service/runtime.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,14 @@ impl Runtime {
612612
fix: message.fix.map(|fix| FixWithPosition {
613613
content: fix.content,
614614
span: SpanPositionMessage::new(
615-
offset_to_position(fix.span.start, source_text),
616-
offset_to_position(fix.span.end, source_text),
615+
offset_to_position(
616+
section.source.start + fix.span.start,
617+
source_text,
618+
),
619+
offset_to_position(
620+
section.source.start + fix.span.end,
621+
source_text,
622+
),
617623
)
618624
.with_message(
619625
fix.message

0 commit comments

Comments
 (0)