提交 26ec624a 编写于 作者: R Rachel Macfarlane

Fix position updating on file changes when comment widget has not been opened

上级 734f48c6
......@@ -303,10 +303,22 @@ export class ReviewZoneWidget extends ZoneWidget {
this._localToDispose.push(this.editor.onMouseDown(e => this.onEditorMouseDown(e)));
this._localToDispose.push(this.editor.onMouseUp(e => this.onEditorMouseUp(e)));
this._localToDispose.push(this.editor.onDidChangeModelContent(() => {
if (this._commentGlyph.getPosition().position.lineNumber !== this.position.lineNumber) {
this._localToDispose.push(this.editor.onDidChangeModelContent((e) => {
// If the widget has been opened, the position is set and can be relied on for updating the glyph position
if (this.position && this.position.lineNumber !== this._commentGlyph.getPosition().position.lineNumber) {
this._commentGlyph.setLineNumber(this.position.lineNumber);
this.editor.layoutContentWidget(this._commentGlyph);
} else {
// Otherwise manually calculate position change :(
const positionChange = e.changes.map(change => {
if (change.range.startLineNumber < change.range.endLineNumber) {
return change.range.startLineNumber - change.range.endLineNumber;
} else {
return change.text.split(e.eol).length - 1;
}
}).reduce((prev, curr) => prev + curr, 0);
this._commentGlyph.setLineNumber(this._commentGlyph.getPosition().position.lineNumber + positionChange);
this.editor.layoutContentWidget(this._commentGlyph);
}
}));
var headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册