From 2b4ed09af493de86ecbd5faab83845106e7eb4e8 Mon Sep 17 00:00:00 2001
From: Bob Zeleznik <zzzman@gmail.com>
Date: Tue, 7 Jul 2020 10:20:00 -0400
Subject: fixed potential infinite loop in richtextmenu

---
 src/client/views/nodes/formattedText/RichTextMenu.tsx | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

(limited to 'src/client/views/nodes/formattedText/RichTextMenu.tsx')

diff --git a/src/client/views/nodes/formattedText/RichTextMenu.tsx b/src/client/views/nodes/formattedText/RichTextMenu.tsx
index 9075a6486..f10c425d4 100644
--- a/src/client/views/nodes/formattedText/RichTextMenu.tsx
+++ b/src/client/views/nodes/formattedText/RichTextMenu.tsx
@@ -219,7 +219,7 @@ export default class RichTextMenu extends AntimodeMenu {
     getActiveAlignment() {
         if (this.view) {
             const path = (this.view.state.selection.$from as any).path;
-            for (let i = path.length - 3; i < path.length; i -= 3) {
+            for (let i = path.length - 3; i < path.length && i >= 0; i -= 3) {
                 if (path[i]?.type === this.view.state.schema.nodes.paragraph) {
                     return path[i].attrs.align || "left";
                 }
-- 
cgit v1.2.3-70-g09d2

