Skip to content

Commit 56118ce

Browse files
authored
Don't clear history on new session (#942)
It's sometimes useful to re-use the same commands across sessions.
1 parent d451c30 commit 56118ce

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

lua/dap/repl.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ local M = {}
66
local history = {
77
last = nil,
88
entries = {},
9-
idx = 1
9+
idx = 1,
10+
max_size = 100,
1011
}
1112

1213
local autoscroll = vim.fn.has('nvim-0.7') == 1
@@ -226,6 +227,9 @@ function execute(text)
226227
end
227228
else
228229
history.last = text
230+
if #history.entries == history.max_size then
231+
table.remove(history.entries, 1)
232+
end
229233
table.insert(history.entries, text)
230234
history.idx = #history.entries + 1
231235
end
@@ -245,8 +249,7 @@ function execute(text)
245249
return
246250
elseif vim.tbl_contains(M.commands.clear, text) then
247251
if repl.buf and api.nvim_buf_is_loaded(repl.buf) then
248-
local layer = ui.layer(repl.buf)
249-
layer.render({}, tostring, {}, 0, - 1)
252+
M.clear()
250253
end
251254
return
252255
end
@@ -385,9 +388,6 @@ end
385388

386389

387390
function M.clear()
388-
history.last = nil
389-
history.entries = {}
390-
history.idx = 1
391391
if repl.buf and api.nvim_buf_is_loaded(repl.buf) then
392392
local layer = ui.layer(repl.buf)
393393
layer.render({}, tostring, {}, 0, - 1)

0 commit comments

Comments
 (0)