fix: handle standalone multiline strings in run selection - #1788
sb123sb123 wants to merge 3 commits into
Conversation
|
Thank you for working on this. However, I'm not sure if this is the right direction. const doc = ['x <- "', 'a', '"'];
for (const line of [0, 1, 2]) {
assert.strictEqual(extendSelection(line, f, doc.length).startLine, 0);
assert.strictEqual(extendSelection(line, f, doc.length).endLine, 2);
} |
|
Thanks for raising this. The expected result is the complete expression: when the cursor is on any of the three lines, Run Selection should select lines 0–2. I pushed commit 0874bb6 with that behavior and updated the regression to check all three starting lines. The focused selection suite passes 38/38, and the TypeScript compile/check passes. The full suite has 259 passing tests; its two session tests need an R executable that is unavailable in my Windows environment. |
eitsupi
left a comment
There was a problem hiding this comment.
Thank you.
However, I have doubts about introducing a completely new parser just for this feature.
It would require a tremendous amount of effort to fully cover rawastring and other features, and I think it would create a structure that is prone to introducing bugs.
|
Thank you for the feedback. The latest revision removes the line-prefix helper and limits the change to the reported reproduction with the cursor on the first line ( |
Closes #1313
Run Selection now continues scanning across lines while a quoted R string remains open, so invoking it from the line that opens a standalone multi-line string selects the complete expression.
For the input lines
['x <- "', 'a', '"'], callingextendSelection(0, ...)returns{ startLine: 0, endLine: 2 }.Validation:
npm test -- --run out/test/suite/extendSelection.test.js --timeout 20000— 38 passing; pretest compile and TypeScript checks passed.npx eslint src --ext ts— 0 errors, 48 existing warnings.git diff --check— passed.AI assistance was used to investigate and implement the fix.