Repository navigation
Stop metadata load from panicking on a bad pattern - #726
Merged
Merged
Conversation
Indent patterns were compiled on first use, so "(" loaded and then
panicked in increase_indent. A number or bool in TM_COMMENT_START
panicked in from_raw on as_str().unwrap().
A pattern that does not compile now fails from_raw, and the loader
skips that set. A non-string shell variable is dropped, so a later
string marker still loads.
keith-hall
approved these changes
Dec 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
An indent pattern the regex engine rejects, and a comment marker that is not a string, both panic while loading
.tmPreferencesmetadata.Regexcompiles on first use.increaseIndentPatternset to(loaded, thenScopedMetadata::increase_indentpanicked.TM_COMMENT_STARTset to a number panicked inMetadataSet::from_rawonas_str().unwrap(). Syntax patterns are already checked withRegex::try_compileat load. These metadata fields were not.from_rawnow returns an error when any indent pattern does not compile. The loader already prints that error and skips the set. A shell variable that is not a string is dropped, so a later string marker still becomes the line comment, and the rest of the set still loads.Only
src/parsing/metadata.rschanges.Regex::regexinregex.rsis unchanged. Thatexpectis the syntax path, which already compiles at load.Tests, command
cargo test --features metadata --lib parsing::metadata::tests:metadata_load_rejects_invalid_indent_patternfailed before the change becausefrom_rawreturned the pattern(. It now returns an error that names that pattern.metadata_load_skips_non_string_comment_markerpanicked onas_str().unwrap()before the change. It now loads#fromTM_COMMENT_START_2.metadata_load_skips_non_string_block_comment_markerpanicked the same way on a booleanTM_COMMENT_END. It now loads with no comment marker.testdata/Packages, still pass. TheScopedMetadatadoctest still passes.cargo clippy --all-features --lib -- --deny clippy::panicpasses.No docs file changes. No open issue tracks these two panics. Ref #183 is the metadata discussion, and this pull does not finish that discussion.
Introduced with metadata loading in
33cb5a6and shell variables infcf5e03.