Skip to content

Align record columns at three scopes (record / file / deck) with grid-array exclusions - #56

Merged
magnesj merged 1 commit into
OPM:mainfrom
magnesj:copilot/add-option-to-align-columns
Jun 30, 2026
Merged

Align record columns at three scopes (record / file / deck) with grid-array exclusions#56
magnesj merged 1 commit into
OPM:mainfrom
magnesj:copilot/add-option-to-align-columns

Conversation

@magnesj

@magnesj magnesj commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Adds record-table column alignment at three scopes and fixes related behaviour.

Three alignment scopes (Command Palette + editor right-click)

  • Align Record Columns in Record (opm-flow.alignRecordColumnsRecord) — aligns only the record group under the cursor.
  • Align Record Columns in File (opm-flow.alignRecordColumns) — aligns the whole current file, or the selection when there is one.
  • Align Record Columns in Deck (opm-flow.alignRecordColumnsInDeck) — starts from the active document, follows the INCLUDE chain (resolving PATHS aliases) recursively, and aligns every reachable file in one WorkspaceEdit. 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 large VFPPROD/VFPINJ tables, collapsing their deliberate fixed-width layout and producing tens of thousands of edits across INCLUDEd 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.alignColumnsExcludedKeywords is 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

  • collectDeckIncludeFiles is a pure helper in paths.ts (takes a readLines callback, no filesystem coupling) — unit tested for nested chains, cycle protection, non-INCLUDE keywords, missing files, and PATHS alias resolution. Only INCLUDE is followed; IMPORT / RESTART / GDFILE are not.
  • examples/deck-align/ ships a small self-contained deck (root → $INC alias include → nested include) for exercising the deck command end-to-end.
  • README documents the three scopes, the deck-only defaults, and the comment-ignoring behaviour.
  • Full test suite passes (372 tests), including new align-exclusions.test.ts and paths.test.ts additions.

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.
@magnesj
magnesj merged commit 35c6732 into OPM:main Jun 30, 2026
4 checks passed
@magnesj
magnesj deleted the copilot/add-option-to-align-columns branch June 30, 2026 09:53
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.

1 participant