Skip to content
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

TextEdit: fix crash when hitting SHIFT + TAB around non-ASCII text #3984

Merged
merged 19 commits into from
Mar 12, 2024

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented Feb 6, 2024

Dear emilk.

Leaving aside other function,
I think this is all you need to fix to patch the panic that occurs when Shift + TAB.

Thank you, emilk.

@rustbasic rustbasic changed the title Update text_buffer.rs SHIFT + TAB panic patch Feb 6, 2024
@rustbasic rustbasic changed the title SHIFT + TAB panic patch TextEdit : SHIFT + TAB panic patch Feb 6, 2024
Comment on lines +92 to +97
let remove_len = if self.as_str().chars().nth(line_start.index) == Some('\t') {
Some(1)
} else if self.as_str()[line_start.index..]
} else if self
.as_str()
.chars()
.skip(line_start.index)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iteration over chars two times can be time consuming for a long text. It is better to do that only once

Copy link
Contributor Author

@rustbasic rustbasic Feb 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be, you right.
However, it only works when we press SHIFT + TAB, so we don't need to change it.

@rustbasic
Copy link
Contributor Author

rustbasic commented Feb 11, 2024

@emilk

PR Merge this for egui v0.26.3, Please.
Let's finish this and move on to the next thing.

@emilk emilk changed the title TextEdit : SHIFT + TAB panic patch TextEdit: fix crash when hitting SHIFT + TAB around non-ASCII text Mar 12, 2024
@emilk emilk added bug Something is broken egui crash crash, panic, segfault, freeze, … labels Mar 12, 2024
@emilk emilk merged commit f019032 into emilk:master Mar 12, 2024
21 of 22 checks passed
@rustbasic rustbasic deleted the patch4 branch April 22, 2024 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is broken crash crash, panic, segfault, freeze, … egui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic when pressing Shift + TAB in a TextEdit
3 participants