Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ None 😋
You can add the following settings:

- `LWI.excludedLanguages`: An array of [languages identifiers](https://code.visualstudio.com/docs/languages/identifiers#_known-language-identifiers) for which you wish not to use the 'Line Width Indicator' extension.
- `LWI.minimalLineWidth`: The line width below which the indicator is not displayed (defaults to 1)
- `LWI.breakpoints`: The counter will change to the respective color when its count is below that column's value.
- `LWI.ignoreComment`: A comment that is added to preserve the current line formatting (no wrapping). Depending on your formatter, this will differ.
- `LWI.style.margin`: The space between the text being typed and LWI counter.
Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@
"maxLength": 50,
"pattern": "//\\s[a-z]+"
},
"LWI.minimalLineWidth": {
"type": "number",
"default": 1,
"description": "The minimum width required for the indicator to be displayed.",
"minimum": 0
},
"LWI.style.margin": {
"type": "number",
"default": 10,
Expand Down
3 changes: 2 additions & 1 deletion src/components/LWI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ export class LineWidthIndicator {
appendCounterToLine(document: vscode.TextDocument): void {
const excludedLanguages = vscode.workspace.getConfiguration("LWI").get("excludedLanguages") as string[];
const excluded = excludedLanguages.includes(document.languageId);
const minimalLineWidth = vscode.workspace.getConfiguration("LWI").get("minimalLineWidth") as number;

// change editor if needed
if (this.activeEditor !== vscode.window.activeTextEditor) {
Expand All @@ -131,7 +132,7 @@ export class LineWidthIndicator {
this.counterDecoration.dispose();

// only add new decoration and/or comment if the user typed something on that line previously
if (!excluded && editor && this.counterDecoration && text.length > 0) {
if (!excluded && editor && this.counterDecoration && text.length >= minimalLineWidth) {
this.counterDecoration = vscode.window.createTextEditorDecorationType({ after: this.getDecorDetails(text) });
editor.setDecorations(this.counterDecoration, [new vscode.Range(position, position)]);
}
Expand Down