Repository navigation
Send a /// statement whole when its continuation has a note - #371
Merged
Merged
Conversation
The statement detector matched only a /// at the very end of a line, so 'reg y x /// note' was sent alone. It now reads the document with Sight's lexer, so it follows the same // and /// rules as the language server: notes after ///, strings, block comments, // comments, tight b///, * comments continued with ///, and statement-starting /// lines.
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 1 minute. 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 follow a
///continuation with a note after it. With the cursor onreg price mpg /// controls, followed byweight, robust, it sent only the first line. Stata then ran nothing, because the do-file ended on a///. With the cursor on the second line, it sentweight, robustalone, which fails with r(199). The detector matched only a///at the very end of a line. A bare///worked.The detector now reads the document with Sight's lexer, so it follows the same
//and///rules as the language server (#367, #370). There's no text-level helper insrc/to share, and the lexer is the one place those rules live. A statement goes on to the next line when:///with a space or tab before it, or at the start of a line, ends the line, with or without a note;///line starts a statement (Stata reads the next line with it);*comment continued with///(Stata swallows the next line into the comment).A
///in a string or a//comment doesn't continue, and neither does a tightb///or*////. Send Upward and Send Downward Lines use the same rule.To import the lexer,
client/tsconfig.jsonnow usesbundlermodule resolution instead ofnodenext. Typechecking is--noEmitonly, and esbuild still bundles the extension as CommonJS. The bundle grows by about 30 KB. Detection takes about 10 ms on a 20,000-line file.Behavior changes
reg y x /// note,* note /// x, and a/// noteline at the start of a statement now join the next line. One property test asserted the old behavior for/// note; it now asserts the join.di "a" /* note/*/ " b").di "a ///(a///in an unclosed string) anddi 1 // note ///no longer join the next line. Stata doesn't join them either.ends_with_continuationis gone. Its replacement isfind_joined_lines(text).Not fixed
#delimit ;, Send statement still sends only the lines joined as above, and Stata runs them under#delimit cr. The detector never followed;statements. The docs now say to select the statement with a#delimit ;line before it.Proof:
tests/unit/send-to-stata/statement-detector.test.tscovers notes after///, a chain of noted///lines,///then a blank line,///in strings, tight///,///after/* */,//and*comments, statement-starting///lines, multi-line block comments, Mata,#delimit ;, CRLF, and upward/downward bounds. 14 of its 17 tests fail on main. All four gates pass. Statements the detector extracts from the sample below, run as do-files in StataMP 18:StataMP 18: main's detector vs. this branch
Sample:
Probes for the rules the tests rely on (StataMP 18):
di 1 // note ///thendi 2runs both;* note /// xswallows the next line;di "A" ///then a blank line runsdi "A";x = 1 ////+ 2in a Mata block gives 3;di "P6" /* note/*/ " joined"printsP6 joined.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.