fix(reformat): reformat overwrites content#4672
Merged
scudette merged 2 commits intoVelocidex:masterfrom Feb 21, 2026
Merged
Conversation
Contributor
|
Thanks for this! +1 on the reformat() VQL function idea - it would be very helpful. |
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.
This pull request fixes an issue where the current reformat logic could unintentionally overwrite content following the
queryfield in an artifact. This most commonly affected artifacts that define additional fields such asnotebookorcolumn_types.For example, given the following artifact with a
notebookfield:Running the reformat command (either via CLI or the GUI) would remove the
notebook:line. Subsequent reformats would continue stripping content, producing an invalid artifact such as:The root cause was an off-by-one error in the mutation logic applied to the
queryblock, which caused the reformat operation to extend beyond the intended range. While addressing this, I also identified an issue with howoriginal_end_linewas calculated for chomping indicator nodes (|-). Because these nodes omit the trailing newline, splitting on\nresulted in an incorrect end line calculation.Additionally, the
current_mu.errvalue was never checked when applying mutations that only had a length of one. This has also been resolved by adding an additional check at the beginning of the line iteration.This change corrects these issues and adds regression tests to verify that:
queryblock is preserved.Please let me know if you'd like further clarification, or if there are any changes you'd like made.
I am also considering a refactor of the
artifacts reformatto call areformatVQL function which wraps this functionality, following the pattern that CLI commands are just wrappers around VQL. Let me know if this is also something you'd be interested in me contributing. 😃