From 4f6cd52ee6edac3d64782d96329c6b8893d80991 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Mon, 15 Jan 2024 11:52:21 -0800 Subject: [PATCH] fix: backtracking for cjs --- sandbox/test.ts | 5 +++-- server/src/server.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/sandbox/test.ts b/sandbox/test.ts index 70a4b75..ca31e12 100644 --- a/sandbox/test.ts +++ b/sandbox/test.ts @@ -2,6 +2,7 @@ import * as stylex from "@stylexjs/stylex"; import stylex2 from "@stylexjs/stylex"; import { createTheme as createThemee } from "@stylexjs/stylex"; import { colors, spacing } from "./tokens.stylex"; +const stylex3 = require("@stylexjs/stylex"); // A constant can be used to avoid repeating the media query const DARK = "@media (prefers-color-scheme: dark)"; @@ -19,14 +20,14 @@ export const dracula = createThemee(colors, { lineColor: "red", }); -const styles = stylex.create({ +const styles = stylex3.create({ root: { width: "100%", maxWidth: 800, minHeight: 40, }, child: { - backgroundColor: "", + backgroundColor: "red", content: "", marginBlock: "1rem", }, diff --git a/server/src/server.ts b/server/src/server.ts index 13b561e..09d7044 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -275,7 +275,7 @@ let hasDiagnosticRelatedInformationCapability = false; }, "*"(node) { - if ("span" in node) { + if ("span" in node && node.type !== "VariableDeclaration") { const startSpanRelative = textDocument.positionAt( byteRepresentation.byteOffsetToCharIndex( node.span.start - moduleStart, @@ -827,7 +827,7 @@ let hasDiagnosticRelatedInformationCapability = false; }, "*"(node) { - if ("span" in node) { + if ("span" in node && node.type !== "VariableDeclaration") { const startSpanRelative = document.positionAt( byteRepresentation.byteOffsetToCharIndex( node.span.start - moduleStart, @@ -875,6 +875,8 @@ let hasDiagnosticRelatedInformationCapability = false; }, VariableDeclarator(node) { + console.log(node); + handleRequires(node, stateManager, settings); },