From 276a5b99d56c9f4dbdaef31f9cd70c8f7d9e6966 Mon Sep 17 00:00:00 2001 From: Noboru Saito Date: Tue, 24 Dec 2024 15:54:07 +0900 Subject: [PATCH] Enhance the length check of Contents Fix Panic with irregular character bsContent. --- oviewer/content.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/oviewer/content.go b/oviewer/content.go index 6bfe97b..b616a7b 100644 --- a/oviewer/content.go +++ b/oviewer/content.go @@ -241,11 +241,11 @@ func (st *parseState) backspaceHandle() { st.bsFlag = true st.bsContent = st.lc.last() - if st.bsContent.width == 1 { - st.lc = st.lc[:len(st.lc)-1] + if st.bsContent.width == 2 && len(st.lc) > 1 { + st.lc = st.lc[:len(st.lc)-2] return } - st.lc = st.lc[:len(st.lc)-2] + st.lc = st.lc[:len(st.lc)-1] } // controlCharHandle handles control characters.