Skip to content

fix(code-actions): offer destruct-line on inline matches - #1829

Merged
rgrinberg merged 1 commit into
masterfrom
push-vysoxystqwrp
Aug 1, 2026
Merged

fix(code-actions): offer destruct-line on inline matches#1829
rgrinberg merged 1 commit into
masterfrom
push-vysoxystqwrp

Conversation

@rgrinberg

@rgrinberg rgrinberg commented Jul 24, 2026

Copy link
Copy Markdown
Member

Fixes #1595 by recognizing match expressions embedded in larger lines and accepting ranges that cover the whole match expression.

The implementation isolates match/case discovery in a small pure module backed by Merlin's OCaml lexer, while leaving the existing statement processing unchanged. When a match already has cases, the action asks Merlin for missing cases through the first case belonging to that match.

Quickcheck coverage varies prefixes, cursor positions, whitespace, comments, strings, record updates, and nested matches. End-to-end expectations verify complete edits for multiline matches, same-line cases, matches without cases, record-update scrutinees, and nested matches.

@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch from 564e394 to bce797b Compare July 24, 2026 16:05
@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch 5 times, most recently from df81ac2 to 64bc451 Compare July 25, 2026 03:19
@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch 4 times, most recently from 25d4efa to 849db57 Compare July 25, 2026 04:12
@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch from 849db57 to 9f6d3ac Compare July 26, 2026 05:20
@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch from 9f6d3ac to f56fd35 Compare July 26, 2026 05:29
@rgrinberg
rgrinberg changed the base branch from master to push-qxpzlxyunotr July 26, 2026 05:29
@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch from f56fd35 to 9919ba9 Compare July 26, 2026 05:49
@rgrinberg
rgrinberg changed the base branch from push-qxpzlxyunotr to master July 26, 2026 05:50
@rgrinberg
rgrinberg force-pushed the push-vysoxystqwrp branch 7 times, most recently from 9ee6af7 to ea3013a Compare August 1, 2026 16:09
Lex the source to locate an inline match and its first outer case while
ignoring nested syntax, comments, strings, and record updates. Mask only
the prefix so existing line-oriented destruct processing keeps correct
offsets and can extend incomplete inline matches.

Signed-off-by: Rudi Grinberg <me@rgrinberg.com>
@rgrinberg
rgrinberg merged commit ffb9cb3 into master Aug 1, 2026
4 of 5 checks passed
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.

Suggest Destruct-line (enumerate-cases, use existing match) on the match token of an incomplete pattern match

1 participant