提交 479368e2 编写于 作者: R Rachel Macfarlane

Do not show new comment button on files with no possible commenting ranges

上级 8c5c75f2
......@@ -77,17 +77,17 @@ export class ReviewZoneWidget extends ZoneWidget {
private _toggleAction: Action;
private _commentThread: modes.CommentThread;
private _commentGlyph: CommentGlyphWidget;
public get commentThread(): modes.CommentThread {
return this._commentThread;
}
private _replyCommand: modes.Command;
private _owner: number;
private _decorationIDs: string[];
private _localToDispose: IDisposable[];
public get owner(): number {
return this._owner;
}
private _decorationIDs: string[];
private _localToDispose: IDisposable[];
public get commentThread(): modes.CommentThread {
return this._commentThread;
}
constructor(
editor: ICodeEditor,
......
......@@ -71,6 +71,7 @@ export class ReviewController implements IEditorContribution {
private _commentInfos: modes.CommentInfo[];
private _reviewModel: ReviewModel;
private _newCommentGlyph: CommentGlyphWidget;
private _hasSetComments: boolean;
constructor(
editor: ICodeEditor,
......@@ -90,6 +91,7 @@ export class ReviewController implements IEditorContribution {
this._commentWidgets = [];
this._newCommentWidget = null;
this._newCommentGlyph = null;
this._hasSetComments = false;
this._reviewPanelVisible = ctxReviewPanelVisible.bindTo(contextKeyService);
this._reviewModel = new ReviewModel();
......@@ -161,6 +163,11 @@ export class ReviewController implements IEditorContribution {
this._newCommentWidget = null;
}
if (this._newCommentGlyph) {
this.editor.removeContentWidget(this._newCommentGlyph);
this._newCommentGlyph = null;
}
this._commentWidgets.forEach(zone => {
zone.dispose();
});
......@@ -231,7 +238,12 @@ export class ReviewController implements IEditorContribution {
}
private onEditorMouseMove(e: IEditorMouseEvent): void {
if (e.target.position && e.target.position.lineNumber !== undefined) {
if (!this._hasSetComments) {
return;
}
const hasCommentingRanges = this._commentInfos.length && this._commentInfos.some(info => !!info.commentingRanges.length);
if (hasCommentingRanges && e.target.position && e.target.position.lineNumber !== undefined) {
if (this._newCommentGlyph && e.target.element.className !== 'comment-hint') {
this.editor.removeContentWidget(this._newCommentGlyph);
}
......@@ -251,7 +263,7 @@ export class ReviewController implements IEditorContribution {
}
}
getNewCommentAction(line: number): { replyCommand: modes.Command, ownerId: number } {
private getNewCommentAction(line: number): { replyCommand: modes.Command, ownerId: number } {
for (let i = 0; i < this._commentInfos.length; i++) {
const commentInfo = this._commentInfos[i];
const lineWithinRange = commentInfo.commentingRanges.some(range =>
......@@ -291,6 +303,7 @@ export class ReviewController implements IEditorContribution {
setComments(commentInfos: modes.CommentInfo[]): void {
this._commentInfos = commentInfos;
this._hasSetComments = true;
this.editor.changeDecorations(accessor => {
this.commentingRangeDecorationMap.forEach((val, index) => {
......
......@@ -143,6 +143,11 @@
cursor: text;
}
.monaco-editor .review-widget .body .comment-form .review-thread-reply-button:focus {
outline-style: solid;
outline-width: 1px;
}
.monaco-editor .review-widget .body .comment-form textarea {
display: none;
width: 100%;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册