Skip to content

Commit

Permalink
Add setting to prevent rendering of scrollbar
Browse files Browse the repository at this point in the history
fix: #56
  • Loading branch information
usernamehw committed Aug 18, 2020
1 parent ef31326 commit 57cb358
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Table of contributed settings (prefix "errorLens."):
|infoGutterIconColor|`"#00b7e4"`|Info color of the `circle` gutter icon set.|
|followCursor|`"allLines"`|Highlight only portion of the problems. Possible values: `"allLines"`, `"activeLine"`, `"closestProblem"`.|
|followCursorMore|**`0`**|Augments `followCursor`. Adds number of lines to top and bottom when `followCursor` is `activeLine`. Adds number of closest problems when `followCursor` is `closestProblem`|
|scrollbarHackEnabled|**`false`**|When enabled - prevents showing horizontal scrollbar for decorations. (Might have a conflict with `errorLens.fontFamily` or `errorLens.padding` settings).|

## Commands

Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,11 @@
"type": "string"
},
"markdownDescription": "Exclude files by using glob pattern."
},
"errorLens.scrollbarHackEnabled": {
"type": "boolean",
"default": false,
"markdownDescription": "When enabled - prevents showing horizontal scrollbar for decorations. (Might have a conflict with `errorLens.fontFamily` or `errorLens.padding` settings)."
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions src/decorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ export function setDecorationStyle(): void {

const onlyDigitsRegExp = /^\d+$/;
const fontFamily = extensionConfig.fontFamily ? `font-family:${extensionConfig.fontFamily}` : '';
const fontSize = extensionConfig.fontSize ? `font-size:${onlyDigitsRegExp.test(extensionConfig.fontSize) ? `${extensionConfig.fontSize}px` : extensionConfig.fontSize};line-height:1` : '';
const fontSize = extensionConfig.fontSize ? `font-size:${onlyDigitsRegExp.test(extensionConfig.fontSize) ? `${extensionConfig.fontSize}px` : extensionConfig.fontSize}` : '';
const padding = extensionConfig.padding ? `padding:${onlyDigitsRegExp.test(extensionConfig.padding) ? `${extensionConfig.padding}px` : extensionConfig.padding}` : '';
const margin = `margin-left:${onlyDigitsRegExp.test(extensionConfig.margin) ? `${extensionConfig.margin}px` : extensionConfig.margin}`;
const borderRadius = `border-radius: ${extensionConfig.borderRadius || '0'}`;
const scrollbarHack = extensionConfig.scrollbarHackEnabled ? 'position:absolute' : '';

const afterProps: vscode.ThemableDecorationAttachmentRenderOptions = {
fontStyle: extensionConfig.fontStyleItalic ? 'italic' : 'normal',
fontWeight: extensionConfig.fontWeight,
textDecoration: `;${fontFamily};${fontSize};${padding};${margin};${borderRadius};`,
textDecoration: `none;${fontFamily};${fontSize};${padding};${margin};${borderRadius};${scrollbarHack}`,
};

Global.decorationRenderOptionsError = {
Expand Down
4 changes: 4 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ export interface ExtensionConfig {
* Update decorations only on save
*/
onSave: boolean;
/**
* Prevent scrollbars from appearing for decorations.
*/
scrollbarHackEnabled: boolean;

gutterIconsEnabled: boolean;
gutterIconsFollowCursorOverride: boolean;
Expand Down

0 comments on commit 57cb358

Please sign in to comment.