You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be good to have the option to hide sequences of characters when displaying a document but keep them in the original document. An example would be as follows:
I have used decorators to achieve this and "hide" attributes such as __wid="..." (see code below). However, it results in weird behavior when the cursor is positioned or moved because the characters still exist in the displayed document.
Any ideas on how to implement this nicely?
// create a decorator type that we use to decorate large numbers
var largeNumberDecorationType = vscode.window.createTextEditorDecorationType({
color: 'rgba(0,0,0,0)',
letterSpacing: '-50px',
});
var timeout = null;
let triggerUpdateDecorations = () => {
if (timeout) {
clearTimeout(timeout);
}
timeout = setTimeout(updateDecorations, 500);
}
let updateDecorations = () => {
if (!activeEditor) {
return;
}
var regEx = / __wid="[\w- ]*"/g;
var text = activeEditor.document.getText();
var largeNumbers: vscode.DecorationOptions[] = [];
var match;
while (match = regEx.exec(text)) {
var startPos = activeEditor.document.positionAt(match.index);
var endPos = activeEditor.document.positionAt(match.index + match[0].length);
var decoration = { range: new vscode.Range(startPos, endPos), hoverMessage: match[0] };
largeNumbers.push(decoration);
}
if (this.toggleWidState) {
activeEditor.setDecorations(largeNumberDecorationType, largeNumbers);
}
else {
activeEditor.setDecorations(largeNumberDecorationType, []);
}
}
var activeEditor = vscode.window.activeTextEditor;
if (activeEditor) {
triggerUpdateDecorations();
}
vscode.window.onDidChangeActiveTextEditor(editor => {
activeEditor = editor;
if (editor) {
triggerUpdateDecorations();
}
}, null, context.subscriptions);
vscode.workspace.onDidChangeTextDocument(event => {
if (activeEditor && event.document === activeEditor.document) {
triggerUpdateDecorations();
}
}, null, context.subscriptions);
The text was updated successfully, but these errors were encountered:
This would be a useful feature for pretify-symbols-mode (#2402)...
@raedle to get the cursor to move around the group of characters, I hooked onDidChangeTextEditorSelection and adjusted the cursor position whenever I saw it enter the group. With okay_ish_ results.
And rather than setting the color to black to hide the text, I applied this _unsupported_ decoration: { textDecoration: 'none; font-size: 0.001em', }. For the decoration attachment, I set the font size to 1000em to counteract the shrunken size of its hidden parent. (Beware that there are bugs when the font size gets too small; #9078.)
This feature request will not be considered in the next 6-12 months roadmap and as such will be closed to keep the number of issues we have to maintain actionable. Thanks for understanding and happy coding!
It would be good to have the option to hide sequences of characters when displaying a document but keep them in the original document. An example would be as follows:
Original Document:
Display Document:
I have used decorators to achieve this and "hide" attributes such as __wid="..." (see code below). However, it results in weird behavior when the cursor is positioned or moved because the characters still exist in the displayed document.
Any ideas on how to implement this nicely?
The text was updated successfully, but these errors were encountered: