From 9a4ed16d57409c9c6ef3aa5aa32201fbfccfb2fa Mon Sep 17 00:00:00 2001 From: Sasial <44125644+sasial-dev@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:50:39 +1000 Subject: [PATCH] fix(ui): add `RichText` field (#41) --- packages/ui/src/components/suggestions/suggestions.tsx | 9 +++++---- packages/ui/src/components/suggestions/util.ts | 2 ++ packages/ui/src/components/terminal-window.tsx | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/ui/src/components/suggestions/suggestions.tsx b/packages/ui/src/components/suggestions/suggestions.tsx index 61eb58b4..3e59a2d8 100644 --- a/packages/ui/src/components/suggestions/suggestions.tsx +++ b/packages/ui/src/components/suggestions/suggestions.tsx @@ -41,10 +41,11 @@ export function Suggestions() { return terminalText.parts[terminalText.index]; }, [terminalText]); - const textBoundsParams = useMemo( - () => new Instance("GetTextBoundsParams"), - [], - ); + const textBoundsParams = useMemo(() => { + const params = new Instance("GetTextBoundsParams"); + params.RichText = true; + return params; + }, []); // Suggestions const currentSuggestion = useSelector(selectSuggestion); diff --git a/packages/ui/src/components/suggestions/util.ts b/packages/ui/src/components/suggestions/util.ts index 2beb2186..2094949f 100644 --- a/packages/ui/src/components/suggestions/util.ts +++ b/packages/ui/src/components/suggestions/util.ts @@ -7,6 +7,8 @@ import { import { SuggestionTextBounds } from "./types"; const TEXT_BOUNDS_PARAMS = new Instance("GetTextBoundsParams"); +TEXT_BOUNDS_PARAMS.RichText = true; + const DEFAULT_BOUNDS = new Vector2(); let prevColor: Color3 | undefined; diff --git a/packages/ui/src/components/terminal-window.tsx b/packages/ui/src/components/terminal-window.tsx index 7390d434..c577ab35 100644 --- a/packages/ui/src/components/terminal-window.tsx +++ b/packages/ui/src/components/terminal-window.tsx @@ -49,6 +49,7 @@ export function TerminalWindow() { const textBoundsParams = useMemo(() => { const params = new Instance("GetTextBoundsParams"); + params.RichText = true; params.Width = math.huge; params.Font = options.font.regular; return params;