-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Add Dirty Diff Peek View #13104
Add Dirty Diff Peek View #13104
Conversation
36cfcf1
to
f024b80
Compare
aed2a71
to
8b551e9
Compare
@pisv what am I missing here? Here's what I do:
At this point, I do not get a "dirty diff" annotation in the editor gutter and I have not "Go to next Change" command availlable in command palette. Do I need to enable something? |
@tsmaeder Thank you for taking a look at it. It is very strange that you don't even get dirty diff annotations in the editor gutter. Something seems to be missing indeed. It works for me locally using the following steps, which are based on your steps:
At this point, I get the proper dirty diff annotation(s) in the editor gutter and can browse through the changes using the However, I can confirm that the commands are not available in the command palette. The issue seems to be that the editor loses focus when the command palette is activated, and the commands are enabled only for the currently focused editor. I'll dig into it. |
Here's what I do after building the merge of your branch into master (as per "command line instructions") with the git/git base extensions enabled in the electron app. 2024-02-09.11-40-14.mp4In the last step, I would expect an annotation to appear where the breakpoints are in the editor. |
Maybe a Mac/Windows problem? |
Doing the same workflow on a mac works. The structure of the html looks very different in both cases: the "dirty-diff-glyph" div is missing from the line where the change is. |
I see. Thank you very much for this information. It is clear now that the issue is platform-specific. I'll need some time to set up a Windows VM and debug the issue. |
@tsmaeder I hope that the issues found so far are fixed now. For the sake of convenience, I pushed separate commits, which are intended to be squashed when the review is finished. |
Converted to draft, as the dirty diff peek view no longer works when this PR is rebased on the current master. Perhaps not surprisingly, given that #13217 was merged earlier today... |
Sorry about that. Let me know if you have questions about the update. |
This PR has been rebased on the current master, updated to the new version of |
When I hover over the little red triangle that signifies "removed line", I can get the decorations to keep flickering between the red bar and the triangle icon. Maybe there is an overlap of the decorations that gets the "hover" attribute to flip-flop between states? |
This issue is fixed now in the same way as it was fixed in VS Code about 6 years ago: microsoft/vscode@0026000. Note that the issue can also be reproduced on the current master; it was not introduced by this patch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this very useful PR. The main issue I have is the direct use of monaco API outside of the monaco package: this is making the task of updating to a new VS Code version more tedious. Not sure this is a direction we want to take.
packages/scm/src/browser/decorations/scm-decorations-service.ts
Outdated
Show resolved
Hide resolved
return result.join(''); | ||
} | ||
|
||
class DirtyDiffPeekView extends PeekViewWidget { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is problematic as it adds more direct dependencies on VS Code internals outside of the "monaco" package. This leads to more work each time we want to update to a new version of the monaco editor. I think the right thing to do would be to implement a Theia PeekView
on a Theia editor and to implement the diff, etc. using the Theia editor package, not monaco interfaces. This way, other clients could reuse the view in a way that respects layering.
Thanks for reviewing this PR.
Since this seems to be the main issue, let's try to address it first. Here are my initial thoughts:
Can you explain what exactly I'm missing here? |
@pisv I'll have time to come back to this one probably early next week. |
|
Yes, but that is not a good thing. we have to look at every usage and determine whether it needs updating in the case of a dependency update. VS Code API is internal API that changes without notice and we have to adapt to without any guidance.
That is true, but you're also not making the `PeekView' functionality available for others clients to use. For example, the comments thread widget is using a monaco editor zone widget. While the API of the zone widget implementation is arguably bad (uses VS Code API in its API), at least other Theia modules could reuse some of that implementation.
That is true, and it's also true of the other 27 places that need to be updated in a monaco update. All these "couple of hours" add up. Updating monaco right now is a multi-week endeavor. We should strive to make it easier, not harder.
Keeping all references local to one package and consuming functionality outside that package via well-defined interfaces controllled by ourselves makes it clear what functionality we actually use from the monaco packages. I like to think in terms of "upward" and "downward" interfaces: the "upward" interface is everything VS Code offers internally. The "downward" interfaces is what Theia consumes from this "upward" interface. These interfaces are not the same and sometimes an adaptation layer is needed. Spreading this adaptation layer out makes it hard to understand and control the "downward" interface. It also makes it hard to reuse the adaptation layer, because as in the case of the |
@pisv I resolved all the comments that I don't think need further action. |
@tsmaeder I think I have addressed all of the remaining items except #13104 (comment). Could you please review and resolve them, or provide further feedback? Thank you. |
Hi @pisv , except #13104 (comment) I'm fine with this PR. |
(In reply to #13104 (comment) and #13104 (comment)) If I understand your comments correctly, you ask me to add the necessary API to the After careful consideration of what this would require, I don't think I currently have enough experience in Theia and monaco to design such API properly. I guess that was part of the reason why I decided to take the shortcut of using monaco API directly. I hoped it would not be a problem provided that such usage is well-encapsulated, as described in #13104 (comment). I can understand your concern, but having invested huge amount of time in this PR already, it would probably require even more time and very detailed guidance and prompt review feedback for me to design and implement the necessary API in the desired way. Not sure this would be an optimal direction. |
OK. I'm trying to come up with something in the meantime. Let us see how it goes... |
@pisv very cool, thanks. Rest assured that your efforts are much appreciated. |
Ensure that backslashes in fsPath are escaped in the query JSON.
Ensure that commands for dirty diff navigation are always available. This is consistent with behavior in VS Code, and also with other similar commands (such as `Next Problem/Previous Problem`) in Theia.
Cancel the updateTask when the corresponding editor is disposed.
…onstructed object
Adds the necessary API to the Theia `monaco` package and uses it instead of using monaco internal API directly.
Hi @tsmaeder, The latest commit gets rid of monaco internal API use in
I'm keen to know what you think about it. |
Sounds good, I'll have a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now.
@tsmaeder I'm really glad to hear that you are fine with this PR now. Thank you for your review and approval. |
What it does
Closes #4544.
Allows the user to browse through dirty diff changes similarly to VS Code:
Go to Next Change
/Go to Previous Change
(Alt+F5
/Shift+Alt+F5
) commands move the cursor to the next/previous change.Show Next Change
/Show Previous Change
(Alt+F3
/Shift+Alt+F3
) commands show a peek view with the inline diff of the next/previous change.The peek view can also be opened by clicking on a dirty diff decoration in the gutter. Clicking on the same decoration again closes the peek view.
Basic actions for browsing through the changes and closing the peek view are provided by the peek view itself in its action bar. Other actions such as
Revert Change
andStage Change
can be contributed to the action bar by Theia extensions and VS Code plugins.The implementation fully supports and has been tested with
@theia/git
:and
vscode.git
:How to test
Verify that the following steps work correctly regardless of whether
@theia/git
orvscode.git
is used.Open a file with unstaged changes. The editor should be focused.
Move the cursor to the beginning of the next/previous change by using
Go to Next Change
/Go to Previous Change
(Alt+F5
/Shift+Alt+F5
) commands.Browse through the changes by using
Show Next Change
/Show Previous Change
(Alt+F3
/Shift+Alt+F3
) commands. PressESC
to close the peek view.Click on a dirty diff decoration in the gutter to show the corresponding change. Click on the same decoration again to close the peek view.
Open the peek view again and verify that each of the actions in its action bar (browsing through the changes, closing the peek view, reverting the change, staging the change) works as expected.
Review checklist
Reminder for reviewers