Skip to content

Commit 74d8d8c

Browse files
committed
Make showing the array size an option
1 parent e940be3 commit 74d8d8c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

extension/pages/options.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ <h2>Structure</h2>
7272
<li>
7373
<strong>"indentCStyle"</strong> - <span class="hint">Default false</span>
7474
</li>
75+
<li>
76+
<strong>"showArraySize"</strong> - <span class="hint">Default true</span>
77+
</li>
7578
</ul>
7679
</div>
7780
</header>

extension/src/json-viewer/jsl-format.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jsl.format = (function () {
4545
options = options || {};
4646
var tabSize = options.tabSize || 2;
4747
var indentCStyle = options.indentCStyle || false;
48-
48+
var showArraySize = (typeof options.showArraySize !== "undefined" ? Boolean(options.showArraySize) : true);
4949
var tab = "";
5050
for (var ts = 0; ts < tabSize; ts++) {
5151
tab += " ";
@@ -66,9 +66,11 @@ jsl.format = (function () {
6666
if (!inString) {
6767
if (indentCStyle) newJson += "\n" + repeat(tab, indentLevel);
6868
if(currentChar === "["){
69-
var arraySize = getSizeOfArray(json,i);
70-
if(arraySize !== null){
71-
newJson += "Array[" + arraySize + "]";
69+
if(showArraySize){
70+
var arraySize = getSizeOfArray(json,i);
71+
if(arraySize !== null){
72+
newJson += "Array[" + arraySize + "]";
73+
}
7274
}
7375
}
7476
newJson += currentChar;

extension/src/json-viewer/options/defaults.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = {
1616
lineWrapping: true,
1717
foldGutter: true,
1818
tabSize: 2,
19-
indentCStyle: false
19+
indentCStyle: false,
20+
showArraySize:true
2021
},
2122
style: [
2223
".CodeMirror {",

0 commit comments

Comments
 (0)