Skip to content

Commit eb0723f

Browse files
Fix TextArea cursor dissapearing on Select All when there is no text
1 parent e4389a2 commit eb0723f

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

library/lua/gui/widgets/text_area/text_area_content.lua

+5
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,12 @@ function TextAreaContent:setCursor(cursor_offset)
9898
end
9999

100100
function TextAreaContent:setSelection(from_offset, to_offset)
101+
if #self.text == 0 then
102+
return
103+
end
104+
101105
-- text selection is always start on self.cursor and end on self.sel_end
106+
102107
self:setCursor(from_offset)
103108
self.sel_end = to_offset
104109

test/library/gui/widgets.TextArea.lua

+12
Original file line numberDiff line numberDiff line change
@@ -1655,6 +1655,18 @@ function test.select_all()
16551655
screen:dismiss()
16561656
end
16571657

1658+
function test.ignore_select_all_for_empty_text()
1659+
local text_area, screen, window = arrange_textarea({w=65})
1660+
1661+
expect.eq(read_rendered_text(text_area), '_');
1662+
1663+
simulate_input_keys('CUSTOM_CTRL_A')
1664+
1665+
expect.eq(read_rendered_text(text_area), '_');
1666+
1667+
screen:dismiss()
1668+
end
1669+
16581670
function test.text_key_replace_selection()
16591671
local text_area, screen, window = arrange_textarea({w=65})
16601672

0 commit comments

Comments
 (0)