Skip to content

Commit 1f78ba7

Browse files
committed
🐛 Fixed no scroll on pasting
1 parent a7e0d09 commit 1f78ba7

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "omega"
3-
version = "0.1.9"
3+
version = "0.1.10"
44
repository = "https://github.com/nwrenger/omega"
55
documentation = "https://github.com/nwrenger/omega"
66
readme = "README.md"

src/events.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ pub fn copy(text_area: &mut TextArea) -> Result<()> {
321321
}
322322

323323
/// Pasts the current clipboard
324-
pub fn paste(text_area: &mut TextArea) -> Result<()> {
324+
pub fn paste(s: &mut Cursive, text_area: &mut TextArea) -> Result<()> {
325325
let content = text_area.get_content().to_string();
326326
let cursor_pos = text_area.cursor();
327327

@@ -333,6 +333,13 @@ pub fn paste(text_area: &mut TextArea) -> Result<()> {
333333
let inserted_line = split.0.to_string() + text.as_str() + split.1;
334334
lines[current_line] = inserted_line.as_str();
335335

336+
s.call_on_all_named(
337+
"editor_scroll",
338+
|view: &mut ScrollView<NamedView<TextArea>>| {
339+
view.scroll_to_bottom();
340+
},
341+
);
342+
336343
let new_content: String = lines.join("\n");
337344
text_area.set_content(new_content);
338345

src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ fn main() {
8686
.with_name("editor")
8787
.scrollable()
8888
.scroll_strategy(ScrollStrategy::StickToBottom)
89+
.with_name("editor_scroll")
8990
.full_screen();
9091

9192
let events = OnEventView::new(text_area)
@@ -96,7 +97,7 @@ fn main() {
9697
})
9798
.on_pre_event(Event::CtrlChar('v'), move |s| {
9899
if let Some(mut text_area) = s.find_name::<TextArea>("editor") {
99-
events::paste(&mut text_area).handle(s);
100+
events::paste(s, &mut text_area).handle(s);
100101
}
101102
})
102103
.on_pre_event(Event::CtrlChar('x'), move |s| {

0 commit comments

Comments
 (0)