madskristensen/JavaScriptPrettier

Only update lines that have changed

neoGeneva opened this issue · 6 comments

At the moment if there's a single change made by prettier in a file then the whole files text is replaced, that means every line is shown as changed in VS, and for large files the syntax highlighting takes a little while to re-parse the file which can be a little jarring.

It'd be better if only the changed lines were updated, if possible.

Well there's certainly plenty of diffing libraries in NuGet, though it might be a bit of work figuring out which one performs the best, and produces the best results. There's lots on NPM as well, it might turn out it's easier to do the diff on the Node side of things.

I am unsure of how you'd apply the changes back into the VS text editor, I'm no very familiar with it, but I'm assuming there's a cursor you can use to use to select and delete / change code.

Though maybe I'm oversimplifying the problem, I might give fork this repo and see what happens.

So here's a quick proof on concept, I haven't tested it with many edge cases (single line files or whatever), and I just picked the first NuGet package without any weird dependencies, and I'm guessing doing a bunch of TextBuffer.CreateEdit() / Apply() isn't super efficient.

But I don't think it'd take much to finish it up if others think there's value in it.

neoGeneva@df89085

@madskristensen would you be cool adding reference to a 3rd party library like in @neoGeneva's code referenced above?

Okay, I know bumps aren't kosher, but it's been a year, so @madskristensen whaddya think?