Skip to content

Commit

Permalink
Prevent comment ranges from shifting on edit
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachel Macfarlane committed Aug 15, 2018
1 parent 5bab8f6 commit 22ab03e
Showing 1 changed file with 0 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,24 +299,6 @@ 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((e) => {
// If the widget has been opened, the position is set and can be relied on for updating the glyph position
if (this.position) {
if (this.position.lineNumber !== this._commentGlyph.getPosition().position.lineNumber) {
this._commentGlyph.setLineNumber(this.position.lineNumber);
}
} 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);
}
}));
var headHeight = Math.ceil(this.editor.getConfiguration().lineHeight * 1.2);
this._headElement.style.height = `${headHeight}px`;
this._headElement.style.lineHeight = this._headElement.style.height;
Expand Down

0 comments on commit 22ab03e

Please sign in to comment.