Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could you add the comparison of last two opened document tabs? #7

Closed
ycherkes opened this issue May 20, 2022 · 17 comments
Closed

Could you add the comparison of last two opened document tabs? #7

ycherkes opened this issue May 20, 2022 · 17 comments

Comments

@ycherkes
Copy link

I think it will be very useful to have an option to compare two last opened document tabs like it's done in a Compare plugin of notepad++.
Because it's not necessary that the opened file is a part of the solution. It can be externally opened in Visual Studio.
Is that possible?

@heku
Copy link
Owner

heku commented May 20, 2022

I'm not sure if it's possible to detect what tabs are last opened twos, I need investigate. If this is possible, where to display the 'Compare ...' context menu?

@ycherkes
Copy link
Author

ycherkes commented May 20, 2022

This menu item can be added not to the context menu but rather to the main "File" menu.

@ycherkes
Copy link
Author

ycherkes commented May 20, 2022

The code from the TidyTabs extension can help to figure out the tab opening order.

@heku
Copy link
Owner

heku commented May 20, 2022

Thanks, I will take a look.

@ycherkes
Copy link
Author

Hi @heku,
I think it can be even better to add the context menu "Compare to right tab" and "Compare to left tab". Example can be found here https://github.com/billpratt/CloseTabsToRight.
What do you think?

@heku
Copy link
Owner

heku commented May 28, 2022

This way, user always need move the tab to compare to eithor left or right of current tab firstly, I think this is not more friendly than current approcah - copy the content then 'Compare with Clipboard', let's think again to find if there's any better way.

@ycherkes
Copy link
Author

ycherkes commented May 28, 2022

Let me describe the root of my problem: I have an extension - Object Dumper. It creates the dumps of debugged objects and opens them as separate documents. Those documents are not part of the solution. But I would like to have the ability to compare two of the generated documents. The 'Compare with Clipboard' approach won't work in this case.

@ycherkes
Copy link
Author

ycherkes commented May 28, 2022

I know that the "Miscellaneous Files" can be shown in Solution Explorer, but this option is disabled by default, and not so many people know about that:

image

image

@ycherkes
Copy link
Author

ycherkes commented May 28, 2022

Also, there is an issue because both of them are temporary unsaved files.

ComparisonIssue

Please pay attention to file names in a comparison window:

274

@heku
Copy link
Owner

heku commented May 28, 2022

I see the file name issue, I think I need to look up some vsix docs to fix it.

@ycherkes
Copy link
Author

ycherkes commented May 28, 2022

Yup and not file name issue only - it takes the document's text for an active item from the document, but for the second tries to get it from the file, but the file is empty. That's why I'm asking about the comparison of the two tabs.

@heku
Copy link
Owner

heku commented May 29, 2022

Hi @ycherkes , after a little research, I think we need update our code together to resolve this problem.

Currently this extension supports both VS's builtin file compare service and external tools, these are all based on physical files, i.e. the core API is something like diff(file1, file2).

So, if the physical file contains nothing but VS hold its unsaved changes, then it won't work as your expect, but it looks reasonable to me, for external tools, it's reasonable that they don't know these unsaved content.

And from my test, although VS's builtin diff service take two files path as parameters, seems VS treats them differently, VS loads left file content from physical file, but loads right file with cache (VS unsaved content), that's why left side is empty in your last screenshot.

I also checked your extension's code, looks like you can change this line
https://github.com/ycherkes/ObjectDumper/blob/main/src/ObjectDumper/DumpAsCommandHelper.cs#L140
to

newDocument.Save();

Then VS will save the content to pyhsical temp file too, this should fix the issue you have.

Regarding the file name issue, I'll enhance the code, pass the display name to diff tool.

ycherkes pushed a commit to ycherkes/ObjectDumper that referenced this issue May 29, 2022
@ycherkes
Copy link
Author

Hey @heku,
Thanks a lot for your research.
I've already fixed the document saving issue - bbf47f505b1af57b89b61f985297cca518fcc34b
Thanks a lot, it's amazing :)

@heku
Copy link
Owner

heku commented May 29, 2022

@ycherkes np, thx for the feedback too.

heku added a commit that referenced this issue May 31, 2022
@heku
Copy link
Owner

heku commented May 31, 2022

Hi @ycherkes, the file name issue fixed, could you please test the latest dev branch build https://dev.azure.com/heku/d55bc262-1377-4ae3-9410-4c98cfa53de8/_apis/build/builds/149/artifacts?artifactName=drop&api-version=7.0&%24format=zip
Thanks.

@ycherkes
Copy link
Author

ycherkes commented Jun 1, 2022

Hi @heku, I've tested a VsDiff.2022.vsix, all works fine!
Thank you!

@heku
Copy link
Owner

heku commented Jun 1, 2022

@ycherkes Thanks.

@heku heku closed this as completed Jun 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants