1
- package.loaded [' popup.border' ] = nil
2
-
3
1
local utils = require (' popup.utils' )
4
2
5
3
local Border = {}
@@ -80,7 +78,7 @@ function Border._create_lines(content_win_options, border_win_options)
80
78
return border_lines
81
79
end
82
80
83
- function Border :new (content_buf_id , content_win_id , content_win_options , border_win_options )
81
+ function Border :new (content_bufnr , content_win_id , content_win_options , border_win_options )
84
82
assert (type (content_win_id ) == ' number' , " Must supply a valid win_id. It's possible you forgot to call with ':'" )
85
83
86
84
border_win_options = utils .apply_defaults (border_win_options , {
@@ -104,15 +102,15 @@ function Border:new(content_buf_id, content_win_id, content_win_options, border_
104
102
obj ._border_win_options = border_win_options
105
103
106
104
107
- obj .buf_id = vim .api .nvim_create_buf (false , true )
108
- assert (obj .buf_id , " Failed to create border buffer" )
105
+ obj .bufnr = vim .api .nvim_create_buf (false , true )
106
+ assert (obj .bufnr , " Failed to create border buffer" )
109
107
110
108
obj .contents = Border ._create_lines (content_win_options , border_win_options )
111
- vim .api .nvim_buf_set_lines (obj .buf_id , 0 , - 1 , false , obj .contents )
109
+ vim .api .nvim_buf_set_lines (obj .bufnr , 0 , - 1 , false , obj .contents )
112
110
113
111
local thickness = border_win_options .border_thickness
114
112
115
- obj .win_id = vim .api .nvim_open_win (obj .buf_id , false , {
113
+ obj .win_id = vim .api .nvim_open_win (obj .bufnr , false , {
116
114
anchor = content_win_options .anchor ,
117
115
relative = content_win_options .relative ,
118
116
style = " minimal" ,
@@ -122,15 +120,31 @@ function Border:new(content_buf_id, content_win_id, content_win_options, border_
122
120
height = content_win_options .height + thickness .top + thickness .bot ,
123
121
})
124
122
125
- local silent = true
126
- vim .cmd (
127
- string.format (
128
- " autocmd WinLeave,BufLeave,BufDelete <buffer=%s> ++once ++nested %s call nvim_win_close(%s, v:true)" ,
129
- content_buf_id ,
130
- (silent and " silent!" ) or " " ,
131
- obj .win_id
132
- )
133
- )
123
+ -- local silent = true
124
+ -- vim.cmd(
125
+ -- string.format(
126
+ -- "autocmd WinLeave,BufLeave,BufDelete %s <buffer=%s> ++once ++nested :call popup#close_win(%s, v:true)",
127
+ -- (silent and "<silent>") or "",
128
+ -- content_bufnr,
129
+ -- obj.win_id
130
+ -- )
131
+ -- )
132
+ -- vim.cmd(string.format(
133
+ -- "autocmd WinClosed,BufLeave,BufDelete,WinLeave <silent> <buffer=%s> ++once ++nested :call popup#close_win(%s, v:true)",
134
+ -- content_bufnr,
135
+ -- obj.win_id
136
+ -- ))
137
+ vim .cmd (string.format (
138
+ " autocmd BufLeave,BufDelete <buffer=%s> ++nested ++once :call popup#close_related_win(%s, %s)" ,
139
+ content_bufnr ,
140
+ content_win_id ,
141
+ obj .win_id ))
142
+
143
+ vim .cmd (string.format (
144
+ " autocmd WinClosed,WinLeave <buffer=%s> ++nested ++once :call popup#close_win(%s, v:true)" ,
145
+ content_bufnr ,
146
+ obj .win_id ))
147
+
134
148
135
149
setmetatable (obj , Border )
136
150
0 commit comments