feat(formater): restrict formatting to only the changed range of a file. #4604
feat(formater): restrict formatting to only the changed range of a file. #4604micuintus wants to merge 1 commit intoanomalyco:devfrom
Conversation
917250b to
f4593c6
Compare
f1dc981 to
3e15a39
Compare
df8bdf9 to
0dd5039
Compare
|
@rekram1-node What is the state on this? Are you considering these suggestions? |
|
Yeah I see what you are trying to solve there. I would need some time to look into it more to review but I will say this looks very vibe coded so I won't just auto merge without a throughout review |
Yes, I did use But yeah, this code needs to be reviewed, of course :) I started with the line-number-based range API of clang-format and actually left it as a separate commit (the rest is squashed into the subsequent commit). Then I checked which interface Qt Creator uses: char/byte range API for subfile formatting --- and as it enables us to apply the same logic with Aside from my use case (legacy code bases with humongous unformatted areas): Auto-formatting only the affected part of the file that opencode had touched makes a lot of sense to me; formatting the rest of the file should be a different task / step anyways IMO. Having such a system in place would not only be very beneficial for my workflow, I believe it would make opencode a better tool for everyone. Feel feel to request changes or I'd also be happy to hand this branch over. |
|
@rekram1-node Is there any way I can increase your confidence with that topic? |
f8ee907 to
6a9856d
Compare
d05f216 to
5b0fb78
Compare
@rekram1-node bump :) |
|
this is good we're gonna merge it, aiden will follow up |
|
@micuintus can you update your code to follow some of our style guidelines a bit better? Ex: change changedRanges to just ranges, stuff like that |
5bd0b08 to
762626d
Compare
@rekram1-node Sorry for the delay, I only just saw this. -> Done: 2d47783 Anything else? |
ceebe59 to
50bfdd6
Compare
|
@thdxr @rekram1-node ? 🥺 |
7d3db7d to
31788ba
Compare
798f866 to
ae811ad
Compare
61b5a35 to
3d7a5df
Compare
|
Oof this fell under radar again, u can always reach out via dm |
Ran a review with an llm to check over it, this could be bs:Yes — here is a concrete, numeric proof using the code as written.
|
|
@rekram1-node Thank you. It was not BS, valid points although not critical. |
|
@rekram1-node Private DM... how would I send that? :) |
8ffe542 to
eedde6b
Compare
Add range-restricted formatting to improve performance by only formatting the portions of files that actually changed. Changes: - Add diff-range.ts module to calculate character and byte offset ranges from text diffs, accounting for CRLF/LF normalization and Unicode - Add ranges field to File.Event.Edited event schema - Add optional buildRangeCommand method to formatter Info interface - Implement range commands for prettier, clang-format, and ruff - Calculate and publish ranges in Edit tool for new files and edits
|
@rekram1-node |
Restrict formatting only to the edited line range for clang-format
When using the Edit tool, clang-format now only formats the specific lines
that were changed, rather than reformatting the entire file. This prevents
unrelated formatting changes from cluttering the diff.
Closes #4603