Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playground color for MISSING/ERROR #3029

Open
mingodad opened this issue Feb 16, 2024 · 3 comments · May be fixed by #3042
Open

Playground color for MISSING/ERROR #3029

mingodad opened this issue Feb 16, 2024 · 3 comments · May be fixed by #3042
Labels

Comments

@mingodad
Copy link

Problem

When looking at non trivial input in the playground it's not easy to spot MISSING/ERROR nodes if we could have then with a different color/background-color that would help.

Here is one possible way to allow it (tested locally):

--------------------------- cli/src/playground.html ---------------------------
index 420cd28d..ea2ee843 100644
@@ -172,5 +172,9 @@
       text-decoration: underline red dashed;
       -webkit-text-decoration: underline red dashed;
     }
+
+    a.a-missing, a.a-error {
+	color : blue;
+    }
   </style>
 </body>

------------------------- docs/assets/js/playground.js -------------------------
index c14bf0f5..800a5d17 100644
@@ -146,10 +146,15 @@ let tree;
       }
 
       let displayName;
+      let displayClass = 'plain';
       if (cursor.nodeIsMissing) {
         displayName = `MISSING ${cursor.nodeType}`
+	displayClass += ' a-missing';
       } else if (cursor.nodeIsNamed) {
         displayName = cursor.nodeType;
+	if (displayName == 'ERROR') {
+	  displayClass += ' a-error';
+	}
       }
 
       if (visitedChildren) {
@@ -181,7 +186,7 @@ let tree;
           } else {
             fieldName = '';
           }
-          row = `<div>${'  '.repeat(indentLevel)}${fieldName}<a class='plain' href="#" data-id=${id} data-range="${start.row},${start.column},${end.row},${end.column}">${displayName}</a> [${start.row}, ${start.column}] - [${end.row}, ${end.column}]`;
+          row = `<div>${'  '.repeat(indentLevel)}${fieldName}<a class='${displayClass}' href="#" data-id=${id} data-range="${start.row},${start.column},${end.row},${end.column}">${displayName}</a> [${start.row}, ${start.column}] - [${end.row}, ${end.column}]`;
           finishedRow = true;
         }

Expected behavior

No response

@mingodad mingodad added the enhancement Feature request label Feb 16, 2024
@amaanq
Copy link
Member

amaanq commented Feb 17, 2024

PR welcome if you think it looks good (a screenshot would be nice too)

@mingodad
Copy link
Author

Here is a screenshot:
tree-sitter-missing-error

@mingodad
Copy link
Author

Here is the PR #3042

@ObserverOfTime ObserverOfTime added playground good-first-issue Good issues for first-time contributors wanting to help out and removed good-first-issue Good issues for first-time contributors wanting to help out labels Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants