Skip to content

Commit 1143b70

Browse files
authored
fix(shutdown): better errorhandling to be more sturdy (#82)
1 parent d0a3092 commit 1143b70

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/terminal/init.lua

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,15 @@ do
174174
assert(M.ready(), "terminal not initialized")
175175

176176
-- restore all stacks
177-
local r,c = cursor.position.get() -- Mac: scroll-region reset changes cursor pos to 1,1, so store it
178-
output.write(
179-
cursor.shape.stack.pop_seq(math.huge),
180-
cursor.visible.stack.pop_seq(math.huge),
181-
text.stack.pop_seq(math.huge),
182-
scroll.stack.pop_seq(math.huge),
183-
cursor.position.set_seq(r,c) -- restore cursor pos
184-
)
177+
local ok, r,c = pcall(cursor.position.get) -- Mac: scroll-region reset changes cursor pos to 1,1, so store it
178+
cursor.shape.stack.pop(math.huge)
179+
cursor.visible.stack.pop(math.huge)
180+
text.stack.pop(math.huge)
181+
scroll.stack.pop(math.huge)
182+
183+
if ok and r then
184+
cursor.position.set(r,c) -- restore cursor pos
185+
end
185186
output.flush()
186187

187188
if termbackup.displaybackup then

0 commit comments

Comments
 (0)