-
Notifications
You must be signed in to change notification settings - Fork 36
bug: custom fontSize + alignMessage causes alignment to break #246
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I think vscode-error-lens/package.json Lines 205 to 209 in 6e1190a
No VSCode api to align message, so the decoration is using |
Unless I'm misunderstanding, couldn't you use Example for when using left alignment -- noting that
Results in a left alignment padding of: This alternative approach means it's not trying to use |
You are welcome to make a Pull Request. Alignment logic is:
Getting font size setting value: const editorFontSize = workspace.getConfiguration('editor').get<number>('fontSize')! || 14; |
I just don't know if it works like that: <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="box one">
1
</div>
<div class="box two">
2
</div>
</body>
</html> body {
font-size: 10px;
font-family: Menlo, Monaco, Consolas, 'Courier New', monospace;
}
.box {
border: 1px solid gray;
}
.one {
margin-left: 10ch;
}
.two {
margin-left: calc(10 * 10px);
}
|
Hmm, looks like your right, it takes other things into account behind the scenes. And it ofc looks like VSCode doesn't support any other way of doing that calculation right now (ref: microsoft/vscode#118994). I was messing around, trying to find ways of making margin use a unit of the parent, and doesn't look like there is any option today to do that with Might not be a solid enough solution, but just in case it's something you wanted to look at further: diff --git a/src/decorations/align.ts b/src/decorations/align.ts
index fa347c8..31a1d89 100644
--- a/src/decorations/align.ts
+++ b/src/decorations/align.ts
@@ -88,7 +88,7 @@ export function getStyleForAlignment({
textLine.range.start.line,
textLine.range.end.character,
);
- styleStr = `margin:0 0 0 ${marginChar >= 0 ? marginChar : 0}ch;padding:${padding[0]}ch ${padding[1]}ch`;
+ styleStr = `margin:0 0 0 calc(${marginChar >= 0 ? marginChar : 0} * 0.55rem);padding:${padding[0]}ch ${padding[1]}ch`;
}
return { Essentially Haven't tried it on a web version of vscode to see if it still works the same. Not sure if |
Using the following config:
Causes start alignment to no longer work:

Suspect that the alignment calculation is using the relative font size for the error lens message itself, rather than the editor's font size, thus the skew.
Notes:
errorLens.fontSize
, and the alignment is functional again.Not that big of a deal, as I'm not decreasing font size by much, so I will just disable that setting.
The text was updated successfully, but these errors were encountered: