summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cli/tests/unit/console_test.ts10
-rw-r--r--ext/console/02_console.js8
2 files changed, 15 insertions, 3 deletions
diff --git a/cli/tests/unit/console_test.ts b/cli/tests/unit/console_test.ts
index 0ab2829fc..2fdb23a40 100644
--- a/cli/tests/unit/console_test.ts
+++ b/cli/tests/unit/console_test.ts
@@ -770,6 +770,16 @@ Deno.test(function consoleTestStringifyIterable() {
`[ <1 empty item> ]`,
);
+ assertEquals(
+ stringify([, , 1]),
+ `[ <2 empty items>, 1 ]`,
+ );
+
+ assertEquals(
+ stringify([1, , , 1]),
+ `[ 1, <2 empty items>, 1 ]`,
+ );
+
const withEmptyElAndMoreItems = Array(500);
withEmptyElAndMoreItems.fill(0, 50, 80);
withEmptyElAndMoreItems.fill(2, 100, 120);
diff --git a/ext/console/02_console.js b/ext/console/02_console.js
index efb7aeb50..7554a88fc 100644
--- a/ext/console/02_console.js
+++ b/ext/console/02_console.js
@@ -417,6 +417,7 @@
}
}
+ let entriesLengthWithoutEmptyItems = entriesLength;
if (options.typeName === "Array") {
for (
let i = 0, j = 0;
@@ -433,7 +434,7 @@
if (skipTo) {
// subtract skipped (empty) items
- entriesLength -= skipTo - i;
+ entriesLengthWithoutEmptyItems -= skipTo - i;
i = skipTo;
}
}
@@ -478,8 +479,9 @@
ArrayPrototypeSort(entries);
}
- if (entriesLength > inspectOptions.iterableLimit) {
- const nmore = entriesLength - inspectOptions.iterableLimit;
+ if (entriesLengthWithoutEmptyItems > inspectOptions.iterableLimit) {
+ const nmore = entriesLengthWithoutEmptyItems -
+ inspectOptions.iterableLimit;
ArrayPrototypePush(entries, `... ${nmore} more items`);
}