[英]How to fix VScode gutter indicator artifacts when the text editor is changed?
在我的活動功能中:
const updateTrigger = () => {
if (vscode.window.activeTextEditor) {
updateDecorations(context);
pickupOutJumpPoints(context);
}
};
vscode.window.onDidChangeActiveTextEditor(
updateTrigger,
null,
context.subscriptions
);
更新裝飾品:
const PINLINEDECORATION = vscode.window.createTextEditorDecorationType({
gutterIconPath: PUSHPINPATH,
gutterIconSize: "contain",
rangeBehavior: vscode.DecorationRangeBehavior.ClosedClosed,
});
function updateDecorations(ctx: vscode.ExtensionContext): void {
const jps = getJumpPoints(ctx);
const editor = getEditor();
if (jps === undefined) {
return;
} else {
editor.setDecorations(
PINLINEDECORATION,
jps.map(function (point: JumpPoint): vscode.DecorationOptions {
return {
range: new vscode.Range(point.to.position, point.to.position),
hoverMessage: "$(alert)",
};
})
);
}
}
因為我需要我的裝飾保持固定在一行中,所以每次文本編輯器更改后我都必須重置裝飾,這會產生圖標工件,有沒有更好的方法來實現相同的固定效果?
神器演示: https : //i.gyazo.com/383d8e5979e72131e3b61a33ca8769ae.mp4
默認情況下,裝飾遵循這條線,所以如果你想要“固定到第 8 行”,即使“第 8 行的內容移動到第 9 行”(老實說,我還沒有看到用例),那么你所擁有的就可以了👍🏻
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.