aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index be022e8ae..38a09cb26 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -1742,9 +1742,10 @@ static int lineedit_read_key(char *read_key_buffer)
1742static int isrtl_str(void) 1742static int isrtl_str(void)
1743{ 1743{
1744 int idx = cursor; 1744 int idx = cursor;
1745 while (command_ps[idx] >= ' ' && command_ps[idx] < 127 && !isalpha(command_ps[idx])) 1745
1746 while (idx < command_len && unicode_bidi_is_neutral_wchar(command_ps[idx]))
1746 idx++; 1747 idx++;
1747 return unicode_isrtl(command_ps[idx]); 1748 return unicode_bidi_isrtl(command_ps[idx]);
1748} 1749}
1749#else 1750#else
1750# define isrtl_str() 0 1751# define isrtl_str() 0
@@ -2220,19 +2221,18 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li
2220 command_ps[cursor] = ic; 2221 command_ps[cursor] = ic;
2221 command_ps[cursor + 1] = BB_NUL; 2222 command_ps[cursor + 1] = BB_NUL;
2222 cmdedit_set_out_char(' '); 2223 cmdedit_set_out_char(' ');
2223 if (unicode_isrtl(ic)) 2224 if (unicode_bidi_isrtl(ic))
2224 input_backward(1); 2225 input_backward(1);
2225 } else { 2226 } else {
2226 /* In the middle, insert */ 2227 /* In the middle, insert */
2227 /* is char right-to-left, or "neutral" one (e.g. comma) added to rtl text? */
2228 int rtl = ENABLE_UNICODE_BIDI_SUPPORT ? (unicode_isrtl(ic) || (ic < 127 && !isalpha(ic) && isrtl_str())) : 0;
2229 int sc = cursor; 2228 int sc = cursor;
2230 2229
2231 memmove(command_ps + sc + 1, command_ps + sc, 2230 memmove(command_ps + sc + 1, command_ps + sc,
2232 (command_len - sc) * sizeof(command_ps[0])); 2231 (command_len - sc) * sizeof(command_ps[0]));
2233 command_ps[sc] = ic; 2232 command_ps[sc] = ic;
2234 if (!rtl) 2233 /* is right-to-left char, or neutral one (e.g. comma) was just added to rtl text? */
2235 sc++; 2234 if (!isrtl_str())
2235 sc++; /* no */
2236 /* rewrite from cursor */ 2236 /* rewrite from cursor */
2237 input_end(); 2237 input_end();
2238 /* to prev x pos + 1 */ 2238 /* to prev x pos + 1 */