Repository navigation
Send a #delimit ; statement whole, and run it under #delimit ; - #372
Merged
Merged
Conversation
Send statement now selects the whole ;-terminated statement in a #delimit ; region, using the lexer's delimiter state. Code sent from a ; region (statement, selection, downward lines) gets a #delimit ; line first, since a sent do-file starts under #delimit cr.
Contributor
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. Next included review available in 23 minutes. View limit details
|
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.
Send to Stata didn't know about
#delimit ;. With the cursor in a;region, Send statement sent one line, or only the lines joined by///. Every send also runs as a do-file that starts under#delimit cr. Sodi "A";failed with "A; invalid name",reg price/mpg weight;ran as two broken commands, and a selected;block failed with r(198). Send selection and Send Downward Lines had the same gap.Now, in a
;region, Send statement sends the whole statement up to its;, across as many lines as it takes. The detector gets this from the lexer's delimiter state andSemicolonStatementTracker, so #370's column-0//////rules hold. When the sent code starts in a;region (Send statement, a selection, or Send Downward Lines), it gets a#delimit ;line first. StataMP 18 goes back to#delimit crwhen adoorincludefile ends, so nothing is appended. A trailing#delimit crwould be swallowed by an unterminated statement. Send File and Send Upward Lines start at line 1, so they already carry the file's own#delimitlines.Behavior
;statement are sent with it. A comment after a;(di "A"; // note) doesn't pull the next statement in with it.// c/// d/di "x";is one statement, so it gives r(199) when sent, as it does when the file runs.foreach v in a b {;), each body line, and};are separate statements, as under#delimit cr. A selected block runs whole.mata;…end;block is one statement, as the lexer reads it.#delimit ;line carries it and gets no prefix. One that starts after it gets the prefix.Code changes
statement-detector.ts:read_documentlexes once and returns the joined lines and the#delimitdirectives. The newfind_code_to_sendpicks the code for each send mode and adds the prefix, so it's testable withoutvscode.commands.tscalls it.selection.start, which a realSelectionhas. They now include it.Not changed
Proof: the new
;cases intests/unit/send-to-stata/statement-detector.test.ts(6 of 10 fail on main) andtests/unit/send-to-stata/code-to-send.test.ts(new API; covers the prefix for statements, selections, and upward/downward lines). All four gates pass. In StataMP 18 on voyager, I stepped three;programs statement by statement, as Cmd+Enter with cursor advance would. I ran each send withincludein one interactive session, and compared main's sends with this branch's.StataMP 18: main vs. this branch, stepping three #delimit ; programs
prog1.do:
sysuse auto, clear #delimit ; reg price mpg /// note weight, robust; di "A"; // trailing note di "B"; // leading note summarize price; local a b /// x c; di "[`macval(a)']"; #delimit cr di "cr " 1+1prog2.do:
prog3.do:
Then a selection of prog2 lines 2-6 and Send Downward Lines from prog1 line 11, both with
do. Regression tables and summaries trimmed:Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved
Created with Claude Opus 5.5 in T3 Code (Claude Code harness), reviewed by gpt-6.1-sol in Codex.