scandum / tintin

TinTin++, aka tt++, is an extensible console MUD client.
https://tintin.mudhalla.net
GNU General Public License v3.0
201 stars 56 forks source link

cursor_check_line_modified2 error while editing unicode input #45

Closed 0branch closed 3 years ago

0branch commented 3 years ago

To reproduce with the current HEAD of master (4518ea51),

  1. Input #showme São Paulo (don't press enter)
  2. Hit esc-backspace (or control-w) twice to delete "São Paulo"
    • Note that the cursor lands one position earlier than expected
  3. Press space

I observe the error cursor_check_line_modified2: str: 8 vs 9 after #showme.

Simpler still: input São Paulo and delete two words to the left. The following stacktrace is immediately printed,

debug: goto_pos(68,0)                                                                                               
DEBUG_STACK[000] [000] = mainloop()
DEBUG_STACK[001] [000] = process_input(void)
DEBUG_STACK[002] [001] = check_key(%p,%d)
DEBUG_STACK[003] [001] = cursor_redraw_line(%p,%p)

Pressing space triggers cursor_check_line_modified2 errors as before.

scandum commented 3 years ago

I'm having a hard time reproducing this. Do you have #config charset set to UTF-8 ?

0branch commented 3 years ago

Yes, it's UTF-8; it looks like that's being set on the basis of LANG. If I start TinTin++ like this,

env LANG=C ./tt++

then charset is ASCII and I can no longer reproduce the error.

When I have LANG=en_US.UTF-8 in the environment (as I do on my Mac and Linux machines), #config charset is UTF-8 and the cursor_check_line_modified2 error occurs.

scandum commented 3 years ago

I wonder if your keyboard is sending an 8 bit sequence instead of UTF-8.

Mind telling me the output of #info unicode ã ?

0branch commented 3 years ago

Same output on macOS and Ubuntu,

#info unicode ã                                                                                                       
#INFO UNICODE: ã:  is_utf8_head  = 2 (true)
#INFO UNICODE: ã: get_utf8_size  = 2
#INFO UNICODE: ã: get_utf8_width = 1
#INFO UNICODE: ã: get_utf8_index = 227 (decimal)
#INFO UNICODE: ã: get_utf8_index = e3 (hexadecimal)
scandum commented 3 years ago

That's as expected. So far I haven't been able to reproduce it. Possibly some other setting is involved?

0branch commented 3 years ago

Sure, that's possible—though I'm not sure which setting would be affecting this?

Minor update: bisected and found that the error starts occurring in v2.02.04 (which reworked some of the cursor and UTF-8 logic); I'll try and debug further this weekend.

scandum commented 3 years ago

I must have done something wrong the first time around, but it's generating the error for me now.

I'll holler back once it's fixed.

scandum commented 3 years ago

This should be fixed now in the beta version. https://mudhalla.net/tintin-beta.tar.gz

0branch commented 3 years ago

Thanks. It looks like the beta addresses the reported cases. However, I can still generate similar errors:

  1. Enter São Paulo
  2. Go back two words using the default prev word binding (\eb)

The following stacktrace is output,

debug: goto_pos(34,0)                                                                            
DEBUG_STACK[000] [000] = mainloop()
DEBUG_STACK[001] [000] = process_input(void)
DEBUG_STACK[002] [001] = check_key(%p,%d)
DEBUG_STACK[003] [001] = cursor_redraw_line(%p,%p)
scandum commented 3 years ago

Thanks, updated the beta with a fix for prev word as well.

0branch commented 3 years ago

Thanks; just tested (briefly), couldn't trigger the error.

scandum commented 3 years ago

https://github.com/scandum/tintin/releases/tag/2.02.12