Skip to content

Fix unknown extension crash in completions#2679

Merged
gabritto merged 2 commits intomainfrom
gabritto/fix2669
Feb 4, 2026
Merged

Fix unknown extension crash in completions#2679
gabritto merged 2 commits intomainfrom
gabritto/fix2669

Conversation

@gabritto
Copy link
Copy Markdown
Member

@gabritto gabritto commented Feb 4, 2026

Fixes #2669.

I updated the path completions code to add extensions in more cases compared to Strada (#2610), so now we may include unsupported extensions in path completions, but we shouldn't crash on them.

Copilot AI review requested due to automatic review settings February 4, 2026 18:12
Copy link
Copy Markdown
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 crash in completions when encountering files with unrecognized extensions (e.g., .ruhroh) that are defined as ambient modules.

Changes:

  • Modified kindModifiersFromExtension to gracefully handle unknown file extensions by returning ScriptElementKindModifierNone instead of panicking
  • Added a regression test to ensure completions work correctly with unknown extensions defined in ambient module declarations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
internal/ls/string_completions.go Changed default case in kindModifiersFromExtension to return ScriptElementKindModifierNone instead of panicking, allowing the language server to handle unknown file extensions gracefully
internal/fourslash/tests/completionsPathUnknownExtension_test.go Added a comprehensive test that reproduces the crash scenario from issue #2669 with a .ruhroh extension and verifies completions work without crashing

Comment thread internal/fourslash/tests/completionsPathUnknownExtension_test.go Outdated
@gabritto gabritto added this pull request to the merge queue Feb 4, 2026
Merged via the queue into main with commit 0da6896 Feb 4, 2026
20 checks passed
@gabritto gabritto deleted the gabritto/fix2669 branch February 4, 2026 20:35
Copilot AI pushed a commit that referenced this pull request Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Completions crash for unrecognized ambiently-defined file extensions

3 participants