emilk / emilk/egui

Text goes to newline without pressing enter

Open
#4,837 0 comments 1 reaction 0 assignees View on GitHub
bug
Dominant language
Rust
Stars
30.6k
Forks
2.1k
Avg merge
1d 9h
Merged PRs (30d)
72

Description

**Describe the bug**
When using Multiline widget, the text goes to next line as soon as the current line fills up, it shouldn't happen until unless user press enter, it must render the text in same line as it is default behaviour in text editors, browsers, etc.

**To Reproduce**
```rust
use eframe::egui;

fn main() -> eframe::Result {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default().with_inner_size([320.0, 240.0]),
..Default::default()
};
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Ok(Box::::default())),
)
}

#[derive(Default)]
struct MyApp {
text: String,
}

impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
egui::ScrollArea::both()
.max_width(f32::INFINITY)
.show(ui, |ui| {
ui.add(
egui::TextEdit::multiline(&mut self.text)
.desired_width(f32::INFINITY)
.desired_rows(12)
.lock_focus(true)
.code_editor(),
);
});
});
}
}
```

**Expected behavior**
As soon as the text overflows the current widget width, it should continue in the same line by expanding and create a scrollbar.

**Screenshots**
![image](https://github.com/user-attachments/assets/f7175c44-95d8-40a6-86c8-e63ace759964)

**Desktop (please complete the following information):**
- OS: Windows 11

**Additional context**
I tested it using `glow` OpenGL as renderer

Contributor guide

Open the contributing guide

Research direction

Start with the supplied eframe example, especially TextEdit::multiline, desired_width, ScrollArea, and code_editor, then reproduce the wrapping on Windows or another desktop setup. Trace the multiline widget's width and overflow behavior; done means long text stays on one visual line, expands horizontally, and exposes a scrollbar without requiring Enter.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.