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

Apply TextWrapMode::Extend in TextEdit #4838

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

rustbasic
Copy link
Contributor

@rustbasic rustbasic commented Jul 17, 2024

Apply TextWrapMode::Extend in TextEdit

I'm not sure if this is the correct approach.

@rustbasic rustbasic requested a review from emilk July 31, 2024 07:39
Comment on lines 500 to 504
let wrap_width = if wrap_mode == TextWrapMode::Extend {
f32::INFINITY
} else {
wrap_width
};
Copy link
Owner

Choose a reason for hiding this comment

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

This logic is now only run for the default_layouter, while custom layouters gets the previous wrap_width which ignores wrap_mode.

@rustbasic rustbasic requested a review from emilk July 31, 2024 07:40
f32::INFINITY,
hint_text_font_id,
)
hint_text.into_galley(ui, Some(wrap_mode), f32::INFINITY, hint_text_font_id)
Copy link
Owner

Choose a reason for hiding this comment

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

I think single-line text-edits should always use Extend, otherwise they are not single-line

@@ -481,7 +481,15 @@ impl<'t> TextEdit<'t> {
const MIN_WIDTH: f32 = 24.0; // Never make a [`TextEdit`] more narrow than this.
let available_width = (ui.available_width() - margin.sum().x).at_least(MIN_WIDTH);
let desired_width = desired_width.unwrap_or_else(|| ui.spacing().text_edit_width);
let wrap_width = if ui.layout().horizontal_justify() {

let wrap_mode = ui.style().wrap_mode.unwrap_or(if multiline {
Copy link
Owner

Choose a reason for hiding this comment

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

Should we really use TextWrapMode::Truncate if set? I don't think that will work very well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TextWrapMode::Truncate

I made some changes, but I'm not sure if the changes will work everywhere.

I haven't reviewed the TextWrapMode::Truncate issue.
I'm not sure how TextWrapMode::Truncate is supposed to work with singleline() and multiline(), and what it's intended to do.
How about handling the TextWrapMode::Truncate issue in a new commit?

You can drop this and create a new one.

@rustbasic rustbasic requested a review from emilk July 31, 2024 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text goes to newline without pressing enter
2 participants