Skip to content

Commit e67ae0c

Browse files
committed
Maximum Message Length Fix: #100
1 parent cecd5f6 commit e67ae0c

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"es6": true
66
},
77
"parserOptions": {
8-
"ecmaVersion": 2018,
8+
"ecmaVersion": 2019,
99
"sourceType": "module",
1010
"project": "./tsconfig.json"
1111
},

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ the entire line wherever a diagnostic is generated by the language and also prin
2828
|errorLens.copyProblemMessage|Error Lens: Copy Problem Message|
2929
<!-- COMMANDS_END -->
3030
<!-- SETTINGS_START -->
31-
## Settings (40)
31+
## Settings (41)
3232

3333
> **Error Lens** extension settings start with `errorLens.`
3434
@@ -44,6 +44,7 @@ the entire line wherever a diagnostic is generated by the language and also prin
4444
|borderRadius|"3px"|Border radius of the message. Visible difference when `message` colors are set. [issues/23](https://github.com/usernamehw/vscode-error-lens/issues/23). Example: `5px`.|
4545
|enabledDiagnosticLevels|\["error","warning","info"\]|Customize which diagnostic levels to highlight.|
4646
|messageTemplate|"$message"|Template used for all inline messages. Whitespace between items is important.<br>List of variables:<br>- `$message` - diagnostic message text<br>- `$count` - Number of diagnostics on the line<br>- `$severity` - Severity prefix taken from `#errorLens.severityText#`<br>- `$source` - Source of diagnostic e.g. "eslint"<br>- `$code` - Code of the diagnostic|
47+
|messageMaxChars|**500**|Cut off inline message if it's longer than this value.|
4748
|severityText|\["ERROR","WARNING","INFO","HINT"\]|Replaces `$severity` variable in `#errorLens.messageTemplate#`.|
4849
|messageEnabled|**true**|Controls whether inline message is shown or not (Including background highlight).|
4950
|statusBarIconsEnabled|**false**|When enabled - shows highlighted error/warning icons in status bar.|

package.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,12 @@
162162
"default": "$message",
163163
"markdownDescription": "Template used for all inline messages. Whitespace between items is important.\n\nList of variables:\n\n- `$message` - diagnostic message text\n\n- `$count` - Number of diagnostics on the line\n\n- `$severity` - Severity prefix taken from `#errorLens.severityText#`\n\n- `$source` - Source of diagnostic e.g. \"eslint\"\n\n- `$code` - Code of the diagnostic"
164164
},
165+
"errorLens.messageMaxChars": {
166+
"type": "integer",
167+
"default": 500,
168+
"minimum": 10,
169+
"markdownDescription": "Cut off inline message if it's longer than this value."
170+
},
165171
"errorLens.severityText": {
166172
"type": "array",
167173
"items": {

src/types.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ interface ExtensionConfigType {
4646
* Template used for all inline messages. Interpolates `$message`, `$source`, `$code`, `$count`, `$severity`.
4747
*/
4848
messageTemplate: string;
49+
/**
50+
* Cut off inline message if it's longer than this value.
51+
*/
52+
messageMaxChars: number;
4953
/**
5054
* Replaces `$severity` variable in `#errorLens.messageTemplate#`.
5155
*/

src/utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1+
import { extensionConfig } from 'src/extension';
12
import { Uri } from 'vscode';
23

34
/**
4-
* Cut off string if it's longer than **500** characters.
5+
* Cut off string if it's longer than configured number of characters.
56
*/
67
export function truncateString(str: string): string {
7-
const charLimit = 500;
8-
return str.length > charLimit ? `${str.slice(0, charLimit)}…` : str;
8+
return str.length > extensionConfig.messageMaxChars ? `${str.slice(0, extensionConfig.messageMaxChars)}…` : str;
99
}
1010
/**
1111
* Replace linebreaks with the one whitespace symbol.

0 commit comments

Comments
 (0)