Make Del/Bksp eat whole graphemes

Tested on some zalgo text.
This commit is contained in:
Přemysl Eric Janouch 2017-06-26 04:54:56 +02:00
parent 7d414c7647
commit 2375e0dd3e
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 17 additions and 5 deletions

View File

@ -1724,22 +1724,34 @@ app_editor_process_action (enum action action)
return true; return true;
case ACTION_EDITOR_B_DELETE: case ACTION_EDITOR_B_DELETE:
{
if (g.editor_point < 1) if (g.editor_point < 1)
return false; return false;
app_editor_move (g.editor_point - 1, g.editor_point, int len = 1;
while (g.editor_point - len > 0
&& !g.editor_w[g.editor_point - len])
len++;
app_editor_move (g.editor_point - len, g.editor_point,
g.editor_len - g.editor_point); g.editor_len - g.editor_point);
g.editor_len--; g.editor_len -= len;
g.editor_point--; g.editor_point -= len;
app_editor_changed (); app_editor_changed ();
return true; return true;
}
case ACTION_EDITOR_F_DELETE: case ACTION_EDITOR_F_DELETE:
{
if (g.editor_point + 1 > (int) g.editor_len) if (g.editor_point + 1 > (int) g.editor_len)
return false; return false;
g.editor_len--; int len = 1;
app_editor_move (g.editor_point, g.editor_point + 1, while (g.editor_point + len < (int) g.editor_len
&& !g.editor_w[g.editor_point + len])
len++;
g.editor_len -= len;
app_editor_move (g.editor_point, g.editor_point + len,
g.editor_len - g.editor_point); g.editor_len - g.editor_point);
app_editor_changed (); app_editor_changed ();
return true; return true;
}
case ACTION_EDITOR_B_KILL_WORD: case ACTION_EDITOR_B_KILL_WORD:
{ {
if (g.editor_point < 1) if (g.editor_point < 1)