From 8116d7ad4b0e172c684be58e7184d6e17513a0ac Mon Sep 17 00:00:00 2001 From: nadrad Date: Sun, 25 Sep 2022 08:58:19 +0200 Subject: [PATCH] fixed ctrl+backspace bug --- h-m-m | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/h-m-m b/h-m-m index d4bd3af..e747316 100755 --- a/h-m-m +++ b/h-m-m @@ -1148,9 +1148,26 @@ function magic_readline(&$mm, $title) // ctrl+backspace elseif ($in=="\010") { - $from = max(0, mb_strrpos($title, ' ', max(0,min(1,$cursor-mb_strlen($title)-3)))); - $title = mb_substr($title, 0, $from) . mb_substr($title,$cursor-1); - $cursor = $from+1; + $from = + max + ( + 0 + ,mb_strrpos + ( + $title + ,' ' + ,max + ( + -mb_strlen($title) + ,$cursor-mb_strlen($title)-3 + ) + ) + ) + ; + $title = + mb_substr($title, 0, $from + ($from>0) ) + .mb_substr($title, $cursor-1); + $cursor = $from+1+($from>0); } // backspace @@ -1318,7 +1335,7 @@ function edit_node(&$mm, $rewrite = false) if ( ( - $mm['active_node']==$mm['root_id'] + $mm['active_node']==$mm['root_id'] && $title=='root' ) or $title=='NEW'