File tree Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Expand file tree Collapse file tree 2 files changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -175,6 +175,18 @@ export async function open(
175
175
} ;
176
176
}
177
177
178
+ /**
179
+ * Close popup window
180
+ */
181
+ export async function close (
182
+ denops : Denops ,
183
+ winid : number ,
184
+ ) : Promise < void > {
185
+ const close = denops . meta . host === "vim" ? closePopupVim : closePopupNvim ;
186
+ await close ( denops , winid ) ;
187
+ await denops . redraw ( ) ;
188
+ }
189
+
178
190
/**
179
191
* Config a popup window in Vim/Neovim compatible way.
180
192
*
Original file line number Diff line number Diff line change @@ -105,5 +105,28 @@ test({
105
105
} ,
106
106
} ) ;
107
107
}
108
+
109
+ await t . step ( {
110
+ name : `close() closes a popup window by window ID` ,
111
+ fn : async ( ) => {
112
+ const popupWindow = await popup . open ( denops , {
113
+ relative : "editor" ,
114
+ width : 30 ,
115
+ height : 30 ,
116
+ row : 10 ,
117
+ col : 10 ,
118
+ } ) ;
119
+ const { winid } = popupWindow ;
120
+
121
+ // Verify popup is open
122
+ assertEquals ( await fn . win_gettype ( denops , winid ) , "popup" ) ;
123
+
124
+ // Close using standalone close() function
125
+ await popup . close ( denops , winid ) ;
126
+
127
+ // Verify popup is closed
128
+ assertEquals ( await fn . win_gettype ( denops , winid ) , "unknown" ) ;
129
+ } ,
130
+ } ) ;
108
131
} ,
109
132
} ) ;
You can’t perform that action at this time.
0 commit comments