@@ -5,6 +5,7 @@ local config = require('orgmode.config')
5
5
local namespace = vim .api .nvim_create_namespace (' org_calendar' )
6
6
local colors = require (' orgmode.colors' )
7
7
local Range = require (' orgmode.files.elements.range' )
8
+ local Input = require (' orgmode.ui.input' )
8
9
9
10
--- @alias OrgCalendarOnRenderDayOpts { line : number , from : number , to : number , buf : number , namespace : number }
10
11
--- @alias OrgCalendarOnRenderDay fun ( day : OrgDate , opts : OrgCalendarOnRenderDayOpts )
@@ -71,6 +72,7 @@ function Calendar:open()
71
72
title_pos = ' center' ,
72
73
}
73
74
end
75
+ self .prev_win = vim .api .nvim_get_current_win ()
74
76
75
77
self .buf = vim .api .nvim_create_buf (false , true )
76
78
vim .api .nvim_buf_set_name (self .buf , ' orgcalendar' )
@@ -592,6 +594,7 @@ function Calendar:select()
592
594
593
595
vim .cmd ([[ echon]] )
594
596
vim .api .nvim_win_close (0 , true )
597
+ vim .api .nvim_set_current_win (self .prev_win )
595
598
return cb (selected_date )
596
599
end
597
600
@@ -600,6 +603,7 @@ function Calendar:dispose()
600
603
self .buf = nil
601
604
if self .callback then
602
605
self .callback (nil )
606
+ vim .api .nvim_set_current_win (self .prev_win )
603
607
self .callback = nil
604
608
end
605
609
end
@@ -609,15 +613,16 @@ function Calendar:clear_date()
609
613
self .callback = nil
610
614
vim .cmd ([[ echon]] )
611
615
vim .api .nvim_win_close (0 , true )
616
+ vim .api .nvim_set_current_win (self .prev_win )
612
617
cb (nil , true )
613
618
end
614
619
615
620
function Calendar :read_date ()
616
621
self :_ensure_day ()
617
622
local current_date = self :get_selected_date () or Date .today ()
618
- vim . ui . input ({ prompt = ' Enter date: ' , default = current_date :to_string () }, function (result )
623
+ Input . open ( ' Enter date: ' , current_date :to_string ()): next ( function (result )
619
624
if result then
620
- local date = Date . from_string (result )
625
+ local date = current_date : set_from_string (result )
621
626
if not date then
622
627
date = current_date :adjust (result )
623
628
end
0 commit comments