Skip to content

Conversation

@Sysix
Copy link
Member

@Sysix Sysix commented Oct 14, 2025

The problem is, that get_section_insert_position get the offset after the line break.
But the error offset is before the insert offset. So it gets a range of [4..3].

This rule makes no sense to ignore, because the span will always be 0 with a length of 0.
Ignored the case for adding "ignore fixes" and fixed the panic to make sure, it will not happen for other rules.

closes #14565

@github-actions github-actions bot added the A-editor Area - Editor and Language Server label Oct 14, 2025
Copy link
Member Author

Sysix commented Oct 14, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the C-bug Category - Bug label Oct 14, 2025
@Sysix Sysix force-pushed the 10-14-fix_language_server_fix_panic_when_disable_rule_for_this_line_position_is_after_error_span branch from c2d0c6e to bdb18c3 Compare October 14, 2025 17:49
@Sysix Sysix marked this pull request as ready for review October 14, 2025 17:52
@Sysix Sysix requested a review from camc314 as a code owner October 14, 2025 17:52
Copilot AI review requested due to automatic review settings October 14, 2025 17:52
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a panic in the language server that occurs when trying to add "disable rule for this line" actions when the error position is after the error span. The fix prevents generating ignore fixes for edge cases where the error offset equals the section offset with zero span length, and adds a safety check to prevent slice index panics.

  • Adds early return logic to prevent generating ignore fixes when error is at section boundary with zero span
  • Implements bounds checking in disable_for_this_line to prevent slice index panics
  • Includes comprehensive test coverage for the edge case scenario

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/oxc_language_server/src/linter/error_with_position.rs Core fix with early return logic and bounds checking
crates/oxc_language_server/src/linter/server_linter.rs Integration test for the specific issue
crates/oxc_language_server/fixtures/linter/issue_14565/foo-bar.astro Test fixture file triggering the issue
crates/oxc_language_server/fixtures/linter/issue_14565/.oxlintrc.json Configuration for test case
crates/oxc_language_server/src/snapshots/fixtures_linter_issue_14565@foo-bar.astro.snap Expected test output snapshot

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@Sysix Sysix force-pushed the 10-14-fix_language_server_fix_panic_when_disable_rule_for_this_line_position_is_after_error_span branch from bdb18c3 to 2281506 Compare October 14, 2025 17:53
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Oct 15, 2025
Copy link
Contributor

camc314 commented Oct 15, 2025

Merge activity

@camc314 camc314 self-assigned this Oct 15, 2025
…ition is after error span (#14597)

The problem is, that `get_section_insert_position` get the offset after the line break.
But the error offset is before the insert offset. So it gets a range of `[4..3]`.

This rule makes no sense to ignore, because the span will always be 0 with a length of 0.
Ignored the case for adding "ignore fixes" and fixed the panic to make sure, it will not happen for other rules.

closes #14565
@graphite-app graphite-app bot force-pushed the 10-14-fix_language_server_fix_panic_when_disable_rule_for_this_line_position_is_after_error_span branch from 2281506 to e560cc1 Compare October 15, 2025 21:03
@graphite-app graphite-app bot merged commit e560cc1 into main Oct 15, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 10-14-fix_language_server_fix_panic_when_disable_rule_for_this_line_position_is_after_error_span branch October 15, 2025 21:07
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-editor Area - Editor and Language Server C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

linter: Oxc server crashes in VS Code when opening a .astro with pascalCase filename

3 participants