Skip to content

Commit

Permalink
Update slice-ansi (#565)
Browse files Browse the repository at this point in the history
  • Loading branch information
vadimdemedes committed Mar 24, 2023
1 parent 4a67772 commit e635106
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
3 changes: 1 addition & 2 deletions package.json
Expand Up @@ -49,15 +49,14 @@
"cli-cursor": "^4.0.0",
"cli-truncate": "^3.1.0",
"code-excerpt": "^4.0.0",
"emoji-regex": "^10.2.1",
"indent-string": "^5.0.0",
"is-ci": "^3.0.1",
"lodash": "^4.17.21",
"patch-console": "^2.0.0",
"react-reconciler": "^0.29.0",
"scheduler": "^0.23.0",
"signal-exit": "^3.0.7",
"slice-ansi": "^5.0.0",
"slice-ansi": "^6.0.0",
"stack-utils": "^2.0.6",
"string-width": "^5.1.2",
"type-fest": "^0.12.0",
Expand Down
11 changes: 2 additions & 9 deletions src/output.ts
@@ -1,11 +1,8 @@
import sliceAnsi from 'slice-ansi';
import stringWidth from 'string-width';
import widestLine from 'widest-line';
import createEmojiRegex from 'emoji-regex';
import {type OutputTransformer} from './render-node-to-output.js';

const emojiRegex = createEmojiRegex();

/**
* "Virtual" output class
*
Expand Down Expand Up @@ -187,14 +184,10 @@ export default class Output {
line = transformer(line);
}

// `slice-ansi` counts emojis as one character, not two, so
// indexes must be adjusted to subtract number of emojis
const emojiCount = currentLine.match(emojiRegex)?.length ?? 0;

output[y + offsetY] =
sliceAnsi(currentLine, 0, x - emojiCount) +
sliceAnsi(currentLine, 0, x) +
line +
sliceAnsi(currentLine, x - emojiCount + width);
sliceAnsi(currentLine, x + width);

offsetY++;
}
Expand Down

0 comments on commit e635106

Please sign in to comment.