You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
NOTE: This doesn't pass its test yet. Note that since we're reading the
indentation from the first line, it is expected not to change. However,
a semicolon is added, and the lines outside the range are not changed.
The new approach is roughly:
* Require that the range exactly covers an integer number of lines of the input
* Detect the indentation of the line the range starts on
* Format the range's substring using `printAstToDoc`
* Add enough `indent`s to the doc to restore the detected indentation
* Format the doc to a string with `printDocToString`
* Prepend/append the original input before/after the range
See #1609 (comment)
---
Given `tests/range/range.js`, run the following:
prettier tests/range/range.js --range-start 165 --range-end 246
See the range's text with:
dd if=tests/range/range.js ibs=1 skip=165 count=81 2>/dev/null
Copy file name to clipboardExpand all lines: README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -254,8 +254,8 @@ Prettier ships with a handful of customizable format options, usable in both the
254
254
|**JSX Brackets on Same Line** - Put the `>` of a multi-line JSX element at the end of the last line instead of being alone on the next line |`false`|`--jsx-bracket-same-line`|`jsxBracketSameLine: <bool>`|
255
255
|**Parser** - Specify which parser to use. |`babylon`| <code>--parser <flow|babylon></code> | <code>parser: "<flow|babylon>"</code> |
256
256
|**Semicolons** - Print semicolons at the ends of statements.<br /><br />Valid options: <br /> - `true` - add a semicolon at the end of every statement <br /> - `false` - only add semicolons at the beginning of lines that may introduce ASI failures |`true`|`--no-semi`|`semi: <bool>`|
257
-
|**Range Start** - Format code starting at a given character offset. |`0`|`--range-start <int>`|`rangeStart: <int>`|
258
-
|**Range End** - Format code ending at a given character offset (exclusive). |`Infinity`|`--range-end <int>`|`rangeEnd: <int>`|
257
+
|**Range Start** - Format code starting at a given character offset. The range must begin immediately before the start of a line. |`0`|`--range-start <int>`|`rangeStart: <int>`|
258
+
|**Range End** - Format code ending at a given character offset (exclusive). The range must end immediately after the end of a line. |`Infinity`|`--range-end <int>`|`rangeEnd: <int>`|
0 commit comments