Align record columns at three scopes (record / file / deck) with grid-array exclusions - #56
Merged
Conversation
Add per-scope record-table alignment plus supporting fixes: - Three commands: Align Record Columns in Record (the group under the cursor), in File (current file or selection), and in Deck (follows the INCLUDE chain, resolving PATHS aliases, and aligns every reachable file in one WorkspaceEdit, reporting how many lines/files changed). - The deck sweep skips per-cell grid/region/solution arrays (PORO, PERMX, COORD, SATNUM, ...) and large VFPPROD/VFPINJ tables by default so an INCLUDE'd grid file is not silently rewritten. The in-Record and in-File commands align exactly what was targeted; the user setting alignColumnsExcludedKeywords is honoured by all three and added to the deck defaults. - Alignment and Add Column Headers no longer treat a preceding or interspersed comment as a column heading; columns are positioned from the record data alone and comments are left untouched. Add Column Headers replaces only a heading it previously generated, staying idempotent. - collectDeckIncludeFiles is a pure, unit-tested helper in paths.ts. - examples/deck-align/ ships a self-contained deck for exercising the deck command; README documents all three scopes and the new behaviour.
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.
Summary
Adds record-table column alignment at three scopes and fixes related behaviour.
Three alignment scopes (Command Palette + editor right-click)
opm-flow.alignRecordColumnsRecord) — aligns only the record group under the cursor.opm-flow.alignRecordColumns) — aligns the whole current file, or the selection when there is one.opm-flow.alignRecordColumnsInDeck) — starts from the active document, follows theINCLUDEchain (resolvingPATHSaliases) recursively, and aligns every reachable file in oneWorkspaceEdit. Reports how many record lines and files were changed, and surfaces an error if the edit cannot be applied.Grid/array exclusions (deck sweep only)
A whole-deck sweep used to reformat per-cell grid/region/solution arrays (
PORO,PERMX,COORD,SATNUM, …) and largeVFPPROD/VFPINJtables, collapsing their deliberate fixed-width layout and producing tens of thousands of edits acrossINCLUDEd files. These keywords are now skipped by default for the deck command only (src/align-exclusions.ts).The in Record and in File commands do not apply these defaults — when you align text you explicitly targeted, everything is aligned. The user setting
opm-flow.formatting.alignColumnsExcludedKeywordsis honoured by all three commands and is added to the deck defaults.Comments ignored when aligning / adding headers
Alignment and Add Column Headers no longer treat a preceding or interspersed comment as a column heading. A descriptive comment above a table (e.g.
-- These values are taken from Killough's dataset:) was previously parsed into heading positions and the data aligned to the sentence's words, breaking the layout. Columns are now positioned from the record data alone; comments are left untouched, and Add Column Headers only replaces a heading it previously generated (words equal to the column names), staying idempotent.Implementation notes
collectDeckIncludeFilesis a pure helper inpaths.ts(takes areadLinescallback, no filesystem coupling) — unit tested for nested chains, cycle protection, non-INCLUDEkeywords, missing files, andPATHSalias resolution. OnlyINCLUDEis followed;IMPORT/RESTART/GDFILEare not.examples/deck-align/ships a small self-contained deck (root →$INCalias include → nested include) for exercising the deck command end-to-end.align-exclusions.test.tsandpaths.test.tsadditions.