@@ -16,17 +16,22 @@ local function run_sss_code(codeshot_options, opts)
1616
1717 local copy = false
1818
19- if type (codeshot_options .copy ) == ' string' and codeshot_options .copy ~= " %c " then
19+ if type (codeshot_options .copy ) == ' string' and codeshot_options .copy ~= ' %c ' then
2020 copy = codeshot_options .copy
2121 output = ' raw'
2222 end
2323
24+ if codeshot_options .filename_as_window_title then
25+ local filename = vim .fn .expand (' %:t' )
26+ extra_args .window_title = filename
27+ end
28+
2429 local cmd = table.concat ({
2530 codeshot_options .bin_path ,
2631 table.concat (
2732 utils .obj_to_args (
2833 extra_args ,
29- { ' bin_path' , ' file' , ' raw_input' , ' use_current_theme' , ' output' , ' copy' , ' silent' }
34+ { ' bin_path' , ' file' , ' raw_input' , ' use_current_theme' , ' output' , ' copy' , ' silent' , ' filename_as_window_title ' }
3035 ),
3136 ' '
3237 ),
6469function codeshot .selected_lines ()
6570 local curr = vim .fn .expand (' %:p' )
6671 local extension = vim .fn .expand (' %:e' )
72+
73+ vim .cmd ([[ execute "normal! \<ESC>"]] )
6774 local s_start = vim .fn .getpos (" '<" )[2 ]
6875 local s_end = vim .fn .getpos (" '>" )[2 ]
6976 local lines = s_start .. ' ..' .. s_end
77+
7078 codeshot .take (curr , extension , lines , lines )
7179end
7280
7381function codeshot .focus_selected_lines ()
7482 local curr = vim .fn .expand (' %:p' )
7583 local extension = vim .fn .expand (' %:e' )
84+
85+ vim .cmd ([[ execute "normal! \<ESC>"]] )
7686 local s_start = vim .fn .getpos (" '<" )[2 ]
7787 local s_end = vim .fn .getpos (" '>" )[2 ]
7888 -- Calculate len of lines
7989 -- local n_lines = math.abs(s_end[2] - s_start[2]) + 1
8090 local hi_lines = s_start .. ' ..' .. s_end
91+
8192 codeshot .take (curr , extension , ' ..' , hi_lines )
8293end
8394
0 commit comments