]> git.lizzy.rs Git - linenoise.git/commitdiff
Can't use insert/delete char optimisation on win32
authorSteve Bennett <steveb@workware.net.au>
Mon, 10 Jun 2019 04:52:33 +0000 (14:52 +1000)
committerSteve Bennett <steveb@workware.net.au>
Mon, 10 Jun 2019 04:54:22 +0000 (14:54 +1000)
On win32, everything must go through refreshLine().
It is not possible to use outputChars() directly.

This fixes an assertion failure on win32

Signed-off-by: Steve Bennett <steveb@workware.net.au>
linenoise.c

index 3abc73ccd4ccd3e42ed15cfb1d4581c89cd1efe2..c5520754950a377c612e6405436f31c61bbe8cf3 100644 (file)
@@ -1281,13 +1281,14 @@ static int remove_char(struct current *current, int pos)
         int rc = 1;
 
         /* Now we try to optimise in the simple but very common case that:
-         * - we are remove the char at EOL
+         * - outputChars() can be used directly (not win32)
+         * - we are removing the char at EOL
          * - the buffer is not empty
          * - there are columns available to the left
          * - the char being deleted is not a wide or utf-8 character
          * - no hints are being shown
          */
-        if (current->pos == pos + 1 && current->pos == sb_chars(current->buf) && pos > 0) {
+        if (current->output && current->pos == pos + 1 && current->pos == sb_chars(current->buf) && pos > 0) {
 #ifdef USE_UTF8
             /* Could implement utf8_prev_len() but simplest just to not optimise this case */
             char last = sb_str(current->buf)[offset];
@@ -1342,11 +1343,12 @@ static int insert_char(struct current *current, int pos, int ch)
         buf[n] = 0;
 
         /* Now we try to optimise in the simple but very common case that:
+         * - outputChars() can be used directly (not win32)
          * - we are inserting at EOL
          * - there are enough columns available
          * - no hints are being shown
          */
-        if (pos == current->pos && pos == sb_chars(current->buf)) {
+        if (current->output && pos == current->pos && pos == sb_chars(current->buf)) {
             int width = char_display_width(ch);
             if (current->colsright > width) {
                 /* Yes, can optimise */