Skip to content

Commit 8cb37be

Browse files
authored
fix: Fix copy format (#1091)
* Fix copy formatting problem with empty arrays * Changelog
1 parent 72af4db commit 8cb37be

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/).
66

7+
## [1.39.1]
8+
9+
- Fix copy formatting on empty array.
10+
711
## [1.39.0]
812

913
- Xdebug control socket support for pause on Linux and Windows (Xdebug 3.5).

src/varExport.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@ export async function varExportProperty(property: xdebug.Property, indent: strin
88

99
let displayValue: string
1010
if (property.hasChildren || property.type === 'array' || property.type === 'object') {
11-
if (!property.children || property.children.length === 0) {
12-
// TODO: also take into account the number of children for pagination
13-
property.children = await property.getChildren()
11+
let properties: xdebug.Property[]
12+
if (property.hasChildren) {
13+
if (property.children.length === property.numberOfChildren) {
14+
properties = property.children
15+
} else {
16+
// TODO: also take into account the number of children for pagination
17+
properties = await property.getChildren()
18+
}
19+
} else {
20+
properties = []
1421
}
1522
displayValue = (
1623
await Promise.all(
17-
property.children.map(async property => {
24+
properties.map(async property => {
1825
const indent2 = indent + ' '
1926
if (property.hasChildren) {
2027
return `${indent2}${property.name} => \n${indent2}${await varExportProperty(

src/varJson.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,20 @@ async function _varJsonProperty(property: xdebug.Property, depth: number = 0): P
2020

2121
let displayValue: string
2222
if (property.hasChildren || property.type === 'array' || property.type === 'object') {
23-
if (!property.children || property.children.length === 0) {
24-
// TODO: also take into account the number of children for pagination
25-
property.children = await property.getChildren()
23+
let properties: xdebug.Property[]
24+
if (property.hasChildren) {
25+
if (property.children.length === property.numberOfChildren) {
26+
properties = property.children
27+
} else {
28+
// TODO: also take into account the number of children for pagination
29+
properties = await property.getChildren()
30+
}
31+
} else {
32+
properties = []
2633
}
2734

2835
const obj = await Promise.all(
29-
property.children.map(async property => {
36+
properties.map(async property => {
3037
return [property.name, <object>await _varJsonProperty(property, depth + 1)]
3138
})
3239
)

0 commit comments

Comments
 (0)