From e27ec01b6ef9c07b18abdd8a1a2c4a7522697a89 Mon Sep 17 00:00:00 2001 From: Anirudha <155895067+anirudhaCodes@users.noreply.github.com> Date: Wed, 28 Feb 2024 22:48:16 +0530 Subject: [PATCH] fix: Bug: SetMode method in cursor library does not handle invalid mode values correctly (#477) * fix cursor SetMode * adjust the mode value --- cursor/cursor.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cursor/cursor.go b/cursor/cursor.go index 5abda65..a4f4793 100644 --- a/cursor/cursor.go +++ b/cursor/cursor.go @@ -138,6 +138,10 @@ func (m Model) Mode() Mode { // // For available cursor modes, see type CursorMode. func (m *Model) SetMode(mode Mode) tea.Cmd { + // Adjust the mode value if it's value is out of range + if mode < CursorBlink || mode > CursorHide { + return nil + } m.mode = mode m.Blink = m.mode == CursorHide || !m.focus if mode == CursorBlink {