mirror of
https://github.com/oven-sh/bun
synced 2026-02-10 10:58:56 +00:00
Try using internal string-width in node:readline (#26306)
### What does this PR do? Remove NFKDC normalization and stripVTControlCharacters since Bun.stringWidth does this now ### How did you verify your code works? ci --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -1093,20 +1093,15 @@ pub const String = extern struct {
|
||||
extern fn JSC__createRangeError(*jsc.JSGlobalObject, str: *const String) jsc.JSValue;
|
||||
|
||||
pub fn jsGetStringWidth(globalObject: *jsc.JSGlobalObject, callFrame: *jsc.CallFrame) bun.JSError!jsc.JSValue {
|
||||
const args = callFrame.arguments_old(1).slice();
|
||||
const argument = callFrame.argument(0);
|
||||
const str = try argument.toJSString(globalObject);
|
||||
const view = str.view(globalObject);
|
||||
|
||||
if (args.len == 0 or !args.ptr[0].isString()) {
|
||||
if (view.isEmpty()) {
|
||||
return .jsNumber(@as(i32, 0));
|
||||
}
|
||||
|
||||
const str = try args[0].toBunString(globalObject);
|
||||
defer str.deref();
|
||||
|
||||
if (str.isEmpty()) {
|
||||
return .jsNumber(@as(i32, 0));
|
||||
}
|
||||
|
||||
const width = str.visibleWidth(false);
|
||||
const width = bun.String.init(view).visibleWidth(false);
|
||||
return .jsNumber(width);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user