#Skipping Letters While Typing in VI Like Editor

8 messages · Page 1 of 1 (latest)

strange flax
#

I’m building a vi-like text editor from scratch, and I’m also developing my own curses library for rendering. I’ve encountered an issue where letters are sometimes skipped while typing. I’ve been able to track the cursor movement using logging, but the issue persists in the display.
Problem:

Expected behavior: Each key press should result in the correct letter appearing at the correct cursor position, with the cursor moving accordingly.
Observed behavior: The cursor moves correctly in the log (it increments by one with each key), but sometimes the letter is skipped on the screen while typing.

What I’ve tried:

I’ve implemented logging that records time, row, column, and the character being typed in the format time, row, col, letter to track where the cursor is.
I switch between normal mode and insert mode, logging "normal mode" whenever in normal mode and a key is pressed.
I’ve confirmed that the cursor position in the log updates correctly, but the rendering appears to miss characters intermittently, but with no real pattern

Files of Interest:
~400 lines in total, not big i swear, all in src/
The issue seems related to rendering, and the key files to look at are:

tui.h, tui.cpp
textbuffer.h, textbuffer.cpp
editor.h, editor.cpp

Repo: https://github.com/eric-bodhi/cursey

I suspect there might be an issue with how the rendering is triggered or updated, specifically clearing the screen and the render_file() function but I’m not sure exactly where the problem lies. I've browsed stackoverflow but was not successful.

GitHub

Minimalist Curses like library used in my text editor - eric-bodhi/cursey

tropic dragonBOT
#

When your question is answered use !solved to mark the question as resolved.

Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.

vivid hearth
#

There is a bug in your GapBuffer implementation, nothing to do with TUI.

#

Reproduction: file contents with:

a
b
c

Enter insert mode right away and type this is (space to the end).

strange flax
tropic dragonBOT
#

@strange flax Has your question been resolved? If so, type !solved :)

strange flax
#

found it I think, there was an error in the resizing function (also idk why it was marked constexpr haha) but an off by one error

strange flax
#

!solved