cspell 5.18.1 → 5.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,11 +12,13 @@ function emitSuggestionResult(result, options) {
12
12
  return;
13
13
  }
14
14
  if (verbose) {
15
- const maxWidth = suggestions.map((r) => r.word.length).reduce((max, len) => Math.max(max, len), 0);
15
+ const maxWidth = suggestions
16
+ .map((r) => (0, util_1.width)(r.compoundWord || r.word))
17
+ .reduce((max, len) => Math.max(max, len), 0);
16
18
  for (const sug of suggestions) {
17
19
  const { word, cost, dictionaries, compoundWord } = sug;
18
20
  const w = compoundWord || word;
19
- const padding = ' '.repeat(maxWidth - w.length);
21
+ const padding = ' '.repeat((0, util_1.padWidth)(w, maxWidth));
20
22
  const forbid = sug.forbidden ? chalk.red('X') : ' ';
21
23
  const ignore = sug.noSuggest ? chalk.yellow('N') : ' ';
22
24
  const strCost = (0, util_1.padLeft)(cost.toString(10), 4);
@@ -32,7 +32,7 @@ function emitTraceResults(results, options) {
32
32
  var _a;
33
33
  const maxWordLength = results
34
34
  .map((r) => r.foundWord || r.word)
35
- .reduce((a, b) => Math.max(a, b.length), 'Word'.length);
35
+ .reduce((a, b) => Math.max(a, (0, util_1.width)(b)), 'Word'.length);
36
36
  const cols = {
37
37
  word: maxWordLength,
38
38
  dictName: colWidthDictionaryName,
@@ -66,7 +66,7 @@ function emitTraceResult(r, colWidths, options) {
66
66
  const dictColor = r.dictActive ? chalk.yellowBright : chalk.rgb(200, 128, 50);
67
67
  const n = dictColor(dictName);
68
68
  const info = [w, f, n].join(' ') + ' ';
69
- const used = (0, strip_ansi_1.default)(info).length;
69
+ const used = (0, util_1.width)((0, strip_ansi_1.default)(info));
70
70
  const widthSrc = terminalWidth - used;
71
71
  const c = errors ? chalk.red : chalk.white;
72
72
  const s = c(formatDictionaryLocation(r.dictSource, widthSrc, options.cwd));
@@ -4,7 +4,9 @@ export declare function uniqueFilterFnGenerator<T>(): FilterFn<T>;
4
4
  export declare function uniqueFilterFnGenerator<T, U>(extractFn: (v: T) => U): FilterFn<T>;
5
5
  export declare function unique<T>(src: T[]): T[];
6
6
  export declare function clean<T>(src: T): T;
7
+ export declare function padWidth(s: string, target: number): number;
7
8
  export declare function pad(s: string, w: number): string;
8
9
  export declare function padLeft(s: string, w: number): string;
10
+ export declare function width(s: string): number;
9
11
  export {};
10
12
  //# sourceMappingURL=util.d.ts.map
package/dist/util/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.padLeft = exports.pad = exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
3
+ exports.width = exports.padLeft = exports.pad = exports.padWidth = exports.clean = exports.unique = exports.uniqueFilterFnGenerator = exports.uniqueFn = void 0;
4
4
  // alias for uniqueFilterFnGenerator
5
5
  exports.uniqueFn = uniqueFilterFnGenerator;
6
6
  function uniqueFilterFnGenerator(extractFn) {
@@ -28,16 +28,28 @@ function clean(src) {
28
28
  return r;
29
29
  }
30
30
  exports.clean = clean;
31
+ function padWidth(s, target) {
32
+ const sWidth = width(s);
33
+ return Math.max(target - sWidth, 0);
34
+ }
35
+ exports.padWidth = padWidth;
31
36
  function pad(s, w) {
32
- if (s.length >= w)
37
+ const p = padWidth(s, w);
38
+ if (!p)
33
39
  return s;
34
- return (s + ' '.repeat(w)).slice(0, w);
40
+ return s + ' '.repeat(p);
35
41
  }
36
42
  exports.pad = pad;
37
43
  function padLeft(s, w) {
38
- if (s.length >= w)
44
+ const p = padWidth(s, w);
45
+ if (!p)
39
46
  return s;
40
- return (' '.repeat(w) + s).slice(-w);
47
+ return ' '.repeat(p) + s;
41
48
  }
42
49
  exports.padLeft = padLeft;
50
+ function width(s) {
51
+ // eslint-disable-next-line no-control-regex
52
+ return s.replace(/[\u0300-\u036f\x00-\x1f]/g, '').length;
53
+ }
54
+ exports.width = width;
43
55
  //# sourceMappingURL=util.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cspell",
3
- "version": "5.18.1",
3
+ "version": "5.18.2",
4
4
  "description": "A Spelling Checker for Code!",
5
5
  "funding": "https://github.com/streetsidesoftware/cspell?sponsor=1",
6
6
  "main": "dist/index.js",
@@ -70,13 +70,13 @@
70
70
  },
71
71
  "homepage": "https://streetsidesoftware.github.io/cspell/",
72
72
  "dependencies": {
73
- "@cspell/cspell-pipe": "^5.18.1",
73
+ "@cspell/cspell-pipe": "^5.18.2",
74
74
  "chalk": "^4.1.2",
75
75
  "commander": "^9.0.0",
76
76
  "comment-json": "^4.1.1",
77
- "cspell-gitignore": "^5.18.1",
78
- "cspell-glob": "^5.18.1",
79
- "cspell-lib": "^5.18.1",
77
+ "cspell-gitignore": "^5.18.2",
78
+ "cspell-glob": "^5.18.2",
79
+ "cspell-lib": "^5.18.2",
80
80
  "fast-json-stable-stringify": "^2.1.0",
81
81
  "file-entry-cache": "^6.0.1",
82
82
  "fs-extra": "^10.0.0",
@@ -91,8 +91,8 @@
91
91
  "node": ">=12.13.0"
92
92
  },
93
93
  "devDependencies": {
94
- "@cspell/cspell-json-reporter": "^5.18.1",
95
- "@cspell/cspell-types": "^5.18.1",
94
+ "@cspell/cspell-json-reporter": "^5.18.2",
95
+ "@cspell/cspell-types": "^5.18.2",
96
96
  "@types/file-entry-cache": "^5.0.2",
97
97
  "@types/fs-extra": "^9.0.13",
98
98
  "@types/glob": "^7.2.0",
@@ -104,8 +104,8 @@
104
104
  "micromatch": "^4.0.4",
105
105
  "minimatch": "^3.0.4",
106
106
  "rimraf": "^3.0.2",
107
- "rollup": "^2.66.1",
107
+ "rollup": "^2.67.0",
108
108
  "rollup-plugin-dts": "^4.1.0"
109
109
  },
110
- "gitHead": "8b94979b57a7b1a11f8efbd5bc086d29d496f7be"
110
+ "gitHead": "baa92d5154ccf0a3a27d00ed169dd79cc80ea6cc"
111
111
  }