-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[vscode] introduction of the CommentingRange type #15015
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
Conversation
also fix creation of comments, with arguments passed to the command being the one expected by argument processor fix eclipse-theia#14941 Contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
@rschnekenbu not sure how to test this: is the commenting UI available in Theia before this PR? It's not clear to me how I can invoke the commenting functionality from the video 🤷 Side note: is this an animated gif? If so, that is very inconvenient for Firefox users, because I don't get the video controls: I have to watch it from the start each time I want to go back. |
@tsmaeder , the UI is existing (and was not working) prior to this PR. To test it, you have to compare 2 different files (in my case, a markdown file and a copy of it) using the compare with each other menu when the 2 are selected. In this case, the comment gutter (a grey bar) is shown in the Diff Editor. |
Do you have any error in the log when the app is supposed to activate? |
I see
in the browser log. |
Now I did a "Compare with each other" again. No error in the log this time, but still not gutter. I'm using the 1.59 preview build on Windows for testing this, btw. |
I will test again on my side, but I never see such an issue. I do not get why the contextKeyService shall be disposed. |
@tsmaeder I added some steps to clarify the testing. |
What I was missing is that you need to install the extension in order to make the UI show up 🤷 |
@rschnekenbu I get the "+" signs in the gutter as well on the left side of the left editor in the diff for removed sections. However, when I click on the plus, nothing happens (no error log either). |
@@ -651,8 +653,10 @@ export class CommentActions extends React.Component<CommentActions.Props> { | |||
commands={commands} | |||
node={node} | |||
onClick={() => { | |||
console.log('CommentActions.onClick: ' + commentThread); |
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.
Development leftover?
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.
yes! 🤕
@@ -221,7 +245,8 @@ export class ExtHostCommentThread implements theia.CommentThread, theia.Disposab | |||
readonly onDidUpdateCommentThread = this._onDidUpdateCommentThread.event; | |||
|
|||
set range(range: theia.Range) { | |||
if (!range.isEqual(this._range)) { | |||
if ( ((range === undefined) !== (this._range === undefined)) |
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.
The signature of the range
parameter does not allow it to be undefined. It probably should, considering we're checking for it.
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 now possible to change to an undefined range. Evolution should come later with the ability to create comments without range from the API.
@@ -256,8 +256,8 @@ export class CommentThreadWidget extends BaseWidget { | |||
const frameThickness = Math.round(lineHeight / 9) * 2; | |||
const body = this.zoneWidget.containerNode.getElementsByClassName('body')[0]; | |||
|
|||
const computedLinesNumber = Math.ceil((headHeight + body.clientHeight + arrowHeight + frameThickness + 8 /** margin bottom to avoid margin collapse */) / lineHeight); | |||
this.zoneWidget.show({ afterLineNumber: this._commentThread.range.startLineNumber, heightInLines: computedLinesNumber }); | |||
const computedLinesNumber = Math.ceil((headHeight + body?.clientHeight + arrowHeight + frameThickness + 8 /** margin bottom to avoid margin collapse */) / lineHeight); |
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.
Probably needs body?.clientHeight ?? 0, no?
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.
changed in next commit
if (ranges) { | ||
return ranges.map(x => fromRange(x)); | ||
const commentingRanges: | ||
| theia.Range[] |
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.
Can we not let type inference determine the type here?
fileComments: commentingRanges.enableFileComments | ||
}; | ||
} else { | ||
return commentingRanges ?? undefined; |
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.
We already now that !commentingRanges
here, why not just return undefined
?
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.
indeed, being null or undefined, we don't care as we want undefined only. Removed in next commit.
@tsmaeder could you finally get the comment dialog to open ? |
@rschnekenbu ping? |
@tsmaeder, indeed, the left editor can't have comments. That does not make sense for the set of changes I have introduced, probably some other defect existing prior to this change. But in any case, I will have a look and check why left editor does not support commenting. |
If it's not a regression, I don't have a problem merging this one, but I can't really test that because the plugin does not work without the PR. |
The onMouseDownEvent in comments-contribution.ts is not send when clicking on the left gutter. This seems an issue with the current implementation of the comments contribution and not from the API evolution. |
* [vscode] introduction of the CommentingRange type also fix creation of comments, with arguments passed to the command being the one expected by argument processor fix eclipse-theia#14941 Contributed on behalf of STMicroelectronics Signed-off-by: Remi Schnekenburger <rschnekenburger@eclipsesource.com>
What it does
Introduce the support for Commenting Ranges and capability to create comments on file rather than on a specific range.
also it fixes the creation of comments, with arguments passed to the command being the one expected by argument processor
fix #14941
It is interesting to note that commenting range is supported, but the API do not let the extensions create Thread with not range (see https://github.com/microsoft/vscode/blob/c5549bc00e5f2e17773e9cffa694996fff318772/src/vscode-dts/vscode.d.ts#L17413). So this is hard to test and debug, even on vscode itself... For now, theia code support the ranges to be undefined, but it is not possible to test at runtime. Weird!
How to test
Steps to test:
Using this extension, you get 2 comment providers:
Open the comparison between 2 files (for example, 2 typescript files or 2 markdown files using compare with each other menu
You can see in the diff editor the comment gutter (grey bar) on the side of the text editors, you can create a comment while clicking on the gutter. Notice that the md files have a gutter that is starting every 20 lines for a length of 10 lines. ts files have a gutter for the whole file length.
The UI seems currently broken on comments, I commented on a followup issue for comments action and UI: #12452. (css are bad, actions do no support the 'when' condition, etc.). But this is not relevant for this API implementation
Follow-ups
Improvements on Comment support:
Improvements on buttons and UI: #12452
Breaking changes
Attribution
contributed on behalf of STMicroelectronics
Review checklist
Reminder for reviewers