-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect cursor position after backspacing a Tab? #105
Comments
...and of course my crude fix doesn't work when the Tab in question isn't of width mTabSize because there's text "leaking" into the tab :D I'll come up with a better solution (is there an existing function to convert a character index in a line into a cursor column, taking tabs into account?). |
...ok I came up with an easier fix, just replace the general decrement code with (no need to handle the Tab character specially in this case): mState.mCursorPosition.mColumn = GetCharacterColumn(mState.mCursorPosition.mLine, cindex); I'm not sure what to do with the code that's right above: u.mRemovedStart = u.mRemovedEnd = GetActualCursorCoordinates();
--u.mRemovedStart.mColumn; Is this used for Undo? |
Hi, I just started using ImGuiColorTextEdit and I'm seeing a weird behaviour when backspacing a Tab, however since it's such an obvious thing I'm not sure if the problem is on my side ;)
Basically, given a line like this:
...where the '--------' is a single Tab character (with tab width 8), when the cursor is positioned at the H, and Backspace is pressed (so that the Tab is deleted), the cursor will be positioned at column 7, and not be at the start of the line:
The problem seems to be here, where the cursor position is always decremented by one:
ImGuiColorTextEdit/TextEditor.cpp
Line 1875 in 0a88824
I fix this here like this, checking if the removed character is a Tab, and if yes, decrement by the tabsize. Note the
isTab
and the extra if block where the column is decremented:...it seems to work, but being new to the code base I'm not sure if I overlooked something.
Do you want me to provide a PR for this?
Cheers!
The text was updated successfully, but these errors were encountered: