fix: Bug: SetMode method in cursor library does not handle invalid mode values correctly (#477)

* fix cursor SetMode

* adjust the mode value
This commit is contained in:
Anirudha 2024-02-28 22:48:16 +05:30 committed by GitHub
parent 1029f3164d
commit e27ec01b6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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 {