[gjs: 4/6] integrated the pretty printer to debugger.js




commit fb237b780cf839986fd7970ddda98a8d24e63157
Author: Nasah <nasahnash19 gmail com>
Date:   Wed Jul 20 17:49:32 2022 +0100

    integrated the pretty printer to debugger.js

 modules/script/_bootstrap/debugger.js | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/modules/script/_bootstrap/debugger.js b/modules/script/_bootstrap/debugger.js
index dc42228f5..961fef9ec 100644
--- a/modules/script/_bootstrap/debugger.js
+++ b/modules/script/_bootstrap/debugger.js
@@ -36,17 +36,6 @@ function dvToString(v) {
     return typeof v !== 'object' || v === null ? uneval(v) : `[object ${v.class}]`;
 }
 
-function summarizeObject(dv) {
-    const obj = {};
-    for (var name of dv.getOwnPropertyNames()) {
-        var v = dv.getOwnPropertyDescriptor(name).value;
-        if (v instanceof Debugger.Object)
-            v = '(...)';
-        obj[name] = v;
-    }
-    return obj;
-}
-
 function debuggeeValueToString(dv, style = {pretty: options.pretty}) {
     // Special sentinel values returned by Debugger.Environment.getVariable()
     if (typeof dv === 'object' && dv !== null) {
@@ -71,10 +60,11 @@ function debuggeeValueToString(dv, style = {pretty: options.pretty}) {
     }
 
     if (style.brief)
-        return [dvrepr, JSON.stringify(summarizeObject(dv), null, 4)];
+        return [dvrepr, dvrepr];
 
     const str = debuggeeGlobalWrapper.executeInGlobalWithBindings(
-        'JSON.stringify(v, null, 4)', {v: dv});
+        'imports._print.getPrettyPrintFunction(globalThis)(v)', {v: dv});
+
     if ('throw' in str) {
         if (style.noerror)
             return [dvrepr, undefined];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]