@cjser/cli-truncate 6.1.0-cjser.2 → 6.1.1-cjser.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.
@@ -26,7 +26,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  ));
27
27
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
28
28
 
29
- // packages/@cjser/cli-truncate.tmp-26-1782663828634/index.js
29
+ // packages/@cjser/cli-truncate.tmp-26-1783614088739/index.js
30
30
  var index_exports = {};
31
31
  __export(index_exports, {
32
32
  default: () => cliTruncate
@@ -135,7 +135,7 @@ function cliTruncate(text, columns, options = {}) {
135
135
  }
136
136
  if (position === "start") {
137
137
  if (preferTruncationOnSpace) {
138
- const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
138
+ const nearestSpace = getIndexOfNearestSpace(text, length - columns + (0, import_string_width.default)(truncationCharacter), true);
139
139
  const right2 = (0, import_slice_ansi.default)(text, nearestSpace, length).trim();
140
140
  return prependWithInheritedStyleFromStart(truncationCharacter, right2);
141
141
  }
@@ -163,7 +163,7 @@ function cliTruncate(text, columns, options = {}) {
163
163
  }
164
164
  if (position === "end") {
165
165
  if (preferTruncationOnSpace) {
166
- const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
166
+ const nearestSpace = getIndexOfNearestSpace(text, columns - (0, import_string_width.default)(truncationCharacter));
167
167
  const left2 = (0, import_slice_ansi.default)(text, 0, nearestSpace);
168
168
  return appendWithInheritedStyleFromEnd(left2, truncationCharacter);
169
169
  }
package/index.js CHANGED
@@ -134,7 +134,7 @@ export default function cliTruncate(text, columns, options = {}) {
134
134
 
135
135
  if (position === 'start') {
136
136
  if (preferTruncationOnSpace) {
137
- const nearestSpace = getIndexOfNearestSpace(text, length - columns + 1, true);
137
+ const nearestSpace = getIndexOfNearestSpace(text, length - columns + stringWidth(truncationCharacter), true);
138
138
  const right = sliceAnsi(text, nearestSpace, length).trim();
139
139
  return prependWithInheritedStyleFromStart(truncationCharacter, right);
140
140
  }
@@ -179,7 +179,7 @@ export default function cliTruncate(text, columns, options = {}) {
179
179
 
180
180
  if (position === 'end') {
181
181
  if (preferTruncationOnSpace) {
182
- const nearestSpace = getIndexOfNearestSpace(text, columns - 1);
182
+ const nearestSpace = getIndexOfNearestSpace(text, columns - stringWidth(truncationCharacter));
183
183
  const left = sliceAnsi(text, 0, nearestSpace);
184
184
  return appendWithInheritedStyleFromEnd(left, truncationCharacter);
185
185
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cjser/cli-truncate",
3
- "version": "6.1.0-cjser.2",
3
+ "version": "6.1.1-cjser.2",
4
4
  "description": "Truncate a string to a specific width in the terminal",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -47,7 +47,7 @@
47
47
  ],
48
48
  "dependencies": {
49
49
  "@cjser/slice-ansi": "9.0.0-cjser.2",
50
- "@cjser/string-width": "8.2.1-cjser.2"
50
+ "@cjser/string-width": "8.2.2-cjser.2"
51
51
  },
52
52
  "devDependencies": {
53
53
  "ava": "^7.0.0",
@@ -57,11 +57,11 @@
57
57
  "types": "./index.d.ts",
58
58
  "main": "./dist-cjser/index.cjs",
59
59
  "cjser": {
60
- "sourceVersion": "6.1.0",
60
+ "sourceVersion": "6.1.1",
61
61
  "cjserVersion": 2,
62
62
  "original": {
63
63
  "name": "cli-truncate",
64
- "version": "6.1.0",
64
+ "version": "6.1.1",
65
65
  "exports": {
66
66
  "types": "./index.d.ts",
67
67
  "default": "./index.js"