Skip to content

Conversation

@mdroidian
Copy link
Collaborator

@mdroidian mdroidian commented Nov 11, 2025

Problem submitted by Anup J. via slack

Summary by CodeRabbit

  • Bug Fixes
    • Improved text matching by stripping invisible characters, collapsing excess whitespace, and returning cleaned, trimmed matches for more reliable results.
  • Chores
    • Package version updated (1.7.1 → 1.7.2).

@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces normalizeSpaces in src/settings.ts to strip zero-width characters and collapse whitespace; matching now compares normalized text and returns a cleaned, marker-removed, trimmed string. Also bumps package version from 1.7.1 to 1.7.2.

Changes

Cohort / File(s) Summary
String normalization & matching
src/settings.ts
Added normalizeSpaces helper (remove zero-width chars, collapse whitespace). Use normalizedText for substring comparison. When matched, remove 42Setting markers, trim, and return the cleaned string. Replaced var with let.
Version bump
package.json
Updated version from 1.7.1 to 1.7.2.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Caller
  participant Settings as src/settings.ts
  Note over Settings: New normalizeSpaces helper added
  Caller->>Settings: provide s.text and searchTerm
  Settings->>Settings: normalizedText = normalizeSpaces(s.text)
  Settings->>Settings: if normalizedText contains normalized(searchTerm)
  alt match found
    Settings->>Settings: cleaned = removeMarkers(normalizedText)
    Settings->>Caller: return cleaned.trim()
  else no match
    Settings->>Caller: continue / no match
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Inspect normalizeSpaces for correct handling of zero-width characters and whitespace collapsing.
  • Verify substring matching preserves intended semantics (edge cases with markers).
  • Confirm marker removal and final .trim() do not break callers relying on original spacing or markers.

Poem

🐰 I nibble at spaces, sly and light,
Zero-width shadows vanish from sight,
let hops in where var once lay,
Markers trimmed, strings bounce and play,
A tiny patch, a cleaner day.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Normalize spaces in get setting' accurately describes the main change: introducing space normalization in a settings-related getter function.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 10a84fa and 08727fa.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • package.json (1 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

…is improves the accuracy of setting retrieval by removing unwanted whitespace and zero-width characters.
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/settings.ts (1)

14-16: Consider normalizing settingName for consistent matching.

The function normalizes s.text but not the settingName parameter. If settingName contains zero-width characters or multiple spaces, the includes check (line 15) and the replace call (line 20) might not work as expected.

Apply this diff to ensure consistent normalization:

 export const get = (settingName: string) => {
   let customTrigger = getBlockUidsAndTextsReferencingPage("42Setting");
   let result = null;
+  const normalizedSettingName = normalizeSpaces(settingName);

   for (let s of customTrigger) {
     const normalizedText = normalizeSpaces(s.text);
-    if (normalizedText.includes(settingName)) {
+    if (normalizedText.includes(normalizedSettingName)) {
       result = normalizedText
         .replace("#42Setting ", "")
         .replace("#[[42Setting]] ", "")
         .replace("[[42Setting]] ", "")
-        .replace(settingName, "")
+        .replace(normalizedSettingName, "")
         .trim();
       break;
     }
   }
   return result;
 };

Also applies to: 20-20

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e890c89 and 10a84fa.

📒 Files selected for processing (1)
  • src/settings.ts (1 hunks)
🧰 Additional context used
🪛 Biome (2.1.2)
src/settings.ts

[error] 7-7: A character class cannot match a joined character sequence.

A zero width joiner composes several emojis into a new one. Replace the character class with an alternation.

(lint/suspicious/noMisleadingCharacterClass)

🔇 Additional comments (2)
src/settings.ts (2)

6-7: Static analysis warning is likely a false positive here.

Biome flags \u200D (zero-width joiner) in the character class, noting that it composes emoji sequences. However, since the intent is to strip these characters rather than match composed emojis, the current implementation should work correctly for this use case.


11-11: Good modernization: varlet.

Using let provides proper block scoping and aligns with modern JavaScript best practices.

@mdroidian mdroidian changed the title Normalize spaces in get setting LivePreview - Normalize spaces in get setting Nov 11, 2025
@mdroidian mdroidian merged commit 32fbada into main Nov 11, 2025
1 of 2 checks passed
@mdroidian mdroidian deleted the livepreview-fix-settings branch November 11, 2025 03:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants