diff --git a/library/lua/gui/widgets/text_area.lua b/library/lua/gui/widgets/text_area.lua index c6711f90fd..a23195b133 100644 --- a/library/lua/gui/widgets/text_area.lua +++ b/library/lua/gui/widgets/text_area.lua @@ -55,6 +55,10 @@ function TextArea:getText() return self.subviews.text_area.text end +function TextArea:setText(text) + return self.subviews.text_area:setText(text) +end + function TextArea:getCursor() return self.subviews.text_area.cursor end diff --git a/test/library/gui/widgets.TextArea.lua b/test/library/gui/widgets.TextArea.lua index 15982f7ae6..6be1fe46ae 100644 --- a/test/library/gui/widgets.TextArea.lua +++ b/test/library/gui/widgets.TextArea.lua @@ -2600,3 +2600,20 @@ function test.fast_rewind_reset_selection() screen:dismiss() end + +function test.render_text_set_by_api() + local text_area, screen, window = arrange_textarea({w=80}) + + local text = table.concat({ + 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', + 'Pellentesque dignissim volutpat orci, sed molestie metus elementum vel.', + 'Donec sit amet mattis ligula, ac vestibulum lorem.', + }, '\n') + + text_area:setText(text) + text_area:setCursor(#text + 1) + + expect.eq(read_rendered_text(text_area), text .. '_') + + -- screen:dismiss() +end