ryu1kn / vscode-partial-diff

Visual Studio Code Extension. Take a diff of 2 parts of text(s)
https://marketplace.visualstudio.com/items?itemName=ryu1kn.partial-diff
MIT License
186 stars 16 forks source link

Capture filename in partialdiff uri #66

Open Coteh opened 3 years ago

Coteh commented 3 years ago

Hi, I noticed that when I use the swapdiff VS Code extension to swap two sides of a diff generated with PartialDiff, the filenames in the tab name change.

I believe this is because PartialDiff actually saves the filenames as "text/reg1" and "text/reg2" respectively based on this configuration:

https://github.com/ryu1kn/vscode-partial-diff/blob/cda95b9c2032a70a681c56687eeabbe0d620ab68/src/lib/const.ts#L8-L9

Here's a couple of screenshots that illustrate my point:

Screen Shot 2021-03-21 at 6 27 55 PM Screen Shot 2021-03-21 at 6 28 11 PM

You can see below that the uri for the first PartialDiff file contains just the "reg1" name.

Screen Shot 2021-03-21 at 6 29 01 PM

And the swapdiff extension simply does a swap of the two diffs based on visible editor uris:

https://github.com/shalimski/swapdiff/blob/0a5e83288a9c7ef57b663fb55a0a9b0c18323ccf/src/extension.ts#L22

It seems like there's an open VS Code issue at the moment to allow access to the editor tab label via API https://github.com/microsoft/vscode/issues/41909 so I think the best approach is to capture the original filename (edit: and the line number too) within the PartialDiff filename, whether it's an actual file or an "untitled" file, and then other extensions such as swapdiff can make use of those original filenames.

Is this something that's possible to implement? I would be interested in taking a crack at it myself too if possible. :)