@@ -7,49 +7,53 @@ local action_state = require('telescope.actions.state')
7
7
local seshi = require (' seshi' )
8
8
local utils = require (' seshi.utils' )
9
9
10
- local function list_sessions ()
11
- local sessions = {}
12
- local save_dir = seshi .options .save_dir
13
- local files = vim .fn .glob (save_dir .. ' *' , false , true )
10
+ local function search_sessions (opts )
11
+ opts = opts or {}
14
12
15
- for _ , file in ipairs (files ) do
16
- local session_name = vim .fn .fnamemodify (file , ' :t' )
17
- local dir_path , branch = utils .split_session_filename (session_name )
18
- -- Decode the path and branch
19
- dir_path = utils .decode_path (dir_path )
20
- branch = branch and utils .decode_path (branch ) or nil
13
+ local function list_sessions ()
14
+ local sessions = {}
15
+ local save_dir = seshi .options .save_dir
16
+ local files = vim .fn .glob (save_dir .. ' *' , false , true )
21
17
22
- table.insert (sessions , {
23
- name = session_name ,
24
- file_path = file ,
25
- dir_path = dir_path ,
26
- branch = branch ,
27
- })
28
- end
18
+ for _ , file in ipairs (files ) do
19
+ local session_name = vim .fn .fnamemodify (file , ' :t' )
20
+ local dir_path , branch = utils .split_session_filename (session_name )
21
+ -- Decode the path and branch
22
+ dir_path = utils .decode_path (dir_path )
23
+ branch = branch and utils .decode_path (branch ) or nil
29
24
30
- return sessions
31
- end
25
+ table.insert (sessions , {
26
+ name = session_name ,
27
+ file_path = file ,
28
+ dir_path = dir_path ,
29
+ branch = branch ,
30
+ })
31
+ end
32
32
33
- local function search_sessions (opts )
34
- opts = opts or {}
33
+ return sessions
34
+ end
35
+
36
+ local function make_finder ()
37
+ return finders .new_table ({
38
+ results = list_sessions (),
39
+ entry_maker = function (entry )
40
+ local display = entry .dir_path
41
+ if entry .branch then
42
+ display = display .. ' (' .. entry .branch .. ' )'
43
+ end
44
+ return {
45
+ value = entry ,
46
+ display = display ,
47
+ ordinal = entry .name ,
48
+ }
49
+ end ,
50
+ })
51
+ end
35
52
36
53
pickers
37
54
.new (opts , {
38
55
prompt_title = ' Sessions' ,
39
- finder = finders .new_table ({
40
- results = list_sessions (),
41
- entry_maker = function (entry )
42
- local display = entry .dir_path
43
- if entry .branch then
44
- display = display .. ' (' .. entry .branch .. ' )'
45
- end
46
- return {
47
- value = entry ,
48
- display = display ,
49
- ordinal = entry .name ,
50
- }
51
- end ,
52
- }),
56
+ finder = make_finder (),
53
57
sorter = conf .generic_sorter (opts ),
54
58
attach_mappings = function (prompt_bufnr , map )
55
59
actions .select_default :replace (function ()
@@ -63,6 +67,8 @@ local function search_sessions(opts)
63
67
if selection then
64
68
local file_path = selection .value .file_path
65
69
seshi .delete_session (file_path )
70
+ local current_picker = action_state .get_current_picker (prompt_bufnr )
71
+ current_picker :refresh (make_finder (), { reset_prompt = false })
66
72
end
67
73
end )
68
74
return true
0 commit comments