diff --git a/server/src/capabilities/hover.ts b/server/src/capabilities/hover.ts index cad63b8..44593e5 100644 --- a/server/src/capabilities/hover.ts +++ b/server/src/capabilities/hover.ts @@ -182,7 +182,7 @@ async function onHover({ isStyleXPropertyType(node.callee, stateManager) ) { state.propertyType = dashify(node.callee.property.value); - return; + return state; } state.callInside = null; @@ -306,19 +306,19 @@ async function onHover({ let cssLines: string[] = []; + classLine.reverse(); const propertyName = (state.callInside === "create" || state.callInside === "keyframes" - ? classLine - .reverse() - .find( - (className) => - !( - className.startsWith(":") || - className.startsWith("@") || - className === "default" - ), - ) + ? classLine.find( + (className) => + !( + className.startsWith(":") || + className.startsWith("@") || + className === "default" + ), + ) : `--${state.parentClass[0] || key}`) || "unknown"; + classLine.reverse(); const dashifyPropertyKey = dashify(propertyName); if (propertyType) { @@ -341,8 +341,7 @@ async function onHover({ .slice(0) .filter( (className, index) => - index === 0 || - (className !== "default" && className.startsWith(":")), + index === 0 || className.startsWith(":"), ) .sort() .reverse() diff --git a/server/src/lib/walk.ts b/server/src/lib/walk.ts index 1dbe5c6..9a475c3 100644 --- a/server/src/lib/walk.ts +++ b/server/src/lib/walk.ts @@ -435,12 +435,17 @@ export async function _walk( let result; if ("type" in child) { - result = await _walk(child, visitor, { ...state }, node); + result = await _walk( + child, + visitor, + JSON.parse(JSON.stringify(state)), + node, + ); } else if ("expression" in child) { result = await _walk( child.expression, visitor, - { ...state }, + JSON.parse(JSON.stringify(state)), node, ); } @@ -456,7 +461,7 @@ export async function _walk( const result = await _walk( node[key as keyof typeof node] as unknown as NodeType, visitor, - { ...state }, + JSON.parse(JSON.stringify(state)), node, ); if (result === States.EXIT) {