fix arrow still on first line after text moved

This commit is contained in:
Dan Percic 2021-11-11 18:22:23 +02:00
parent e320dbf6d2
commit acc2f9c7fc

View File

@ -17,6 +17,7 @@ const lineChangeToDecoration = ({ originalEndLineNumber, originalStartLineNumber
},
} as IModelDeltaDecoration);
const isPositive = (lineChange: ILineChange) => lineChange.originalEndLineNumber - lineChange.originalStartLineNumber >= 0;
const notZero = (lineChange: ILineChange) => lineChange.originalEndLineNumber !== 0 && lineChange.originalStartLineNumber !== 0;
@Component({
selector: 'redaction-editor',
@ -122,11 +123,12 @@ export class EditorComponent implements OnInit {
let glyphDecorations = [];
this.diffEditor.onDidUpdateDiff(() => {
/**
* Sometimes diff editor thinks that there's a change that ends on line 0 and starts on line 2000 or so.
* Sometimes diff editor thinks that there's a change that starts on a line greater than 0 and ends on line 0.
* We must get all change that started on a line and ended on the same or greater line
* Otherwise margin buttons will have an odd behaviour
*/
const decorations = this.diffEditor.getLineChanges().filter(isPositive).map(lineChangeToDecoration);
const lineChanges = this.diffEditor.getLineChanges().filter(change => isPositive(change) && notZero(change));
const decorations = lineChanges.map(lineChangeToDecoration);
glyphDecorations = this.diffEditor.getOriginalEditor().deltaDecorations(glyphDecorations, decorations);
});
}