• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

コミットメタ情報

リビジョン898c2c216c59de25a0507cbb29f7f2e7ddd20ad4 (tree)
日時2022-12-15 16:49:23
作者badcoff33 <none@none>
コミッターbadcoff33

ログメッセージ

nvim_win_is_valid makes it more robust

変更サマリ

差分

--- a/lua/utils/popups.lua
+++ b/lua/utils/popups.lua
@@ -1,23 +1,30 @@
11 -- To actually reload the module, we need to remove it from the cache first:
2---package.loaded["utils.popups"] = nil
2+package.loaded["utils.popups"] = nil
33
44 local num_window = 0
5-local delayed_close_time = 2000
5+local delayed_close_time = 3000
66
77 function Popup_One_Liner()
88 local self = {
99 bufnr = nil,
1010 winnr = nil,
11+ winoffset = 0,
1112 }
1213
1314 local open = function(text, duration)
14-
1515 if duration == 0 then
1616 return
1717 end
1818
1919 self.bufnr = vim.api.nvim_create_buf(false, true)
20- vim.api.nvim_buf_set_lines(self.bufnr, 0, -1, true, {" " .. text .. " "})
20+ vim.api.nvim_buf_set_lines(
21+ self.bufnr,
22+ 0,
23+ -1,
24+ true,
25+ { " " .. text .. " " }
26+ )
27+ self.winoffset = num_window
2128 self.winnr = vim.api.nvim_open_win(self.bufnr, false, {
2229 relative = "editor",
2330 anchor = "se",
@@ -50,20 +57,27 @@ function Popup_One_Liner()
5057 end
5158
5259 local update = function(text)
53- if self.winnr == nil then
54- return
60+ if vim.api.nvim_win_is_valid(self.winnr) == true then
61+ vim.api.nvim_win_set_config(self.winnr, {
62+ relative = "editor",
63+ col = vim.o.columns,
64+ row = vim.o.lines - 2 - self.winoffset,
65+ width = #text + 2,
66+ height = 1,
67+ })
68+ vim.api.nvim_buf_set_lines(
69+ self.bufnr,
70+ 0,
71+ -1,
72+ true,
73+ { " " .. text .. " " }
74+ )
5575 end
56-
57- vim.api.nvim_win_set_config(self.winnr, {
58- width = #text + 2,
59- height = 1,
60- })
61- vim.api.nvim_buf_set_lines(self.bufnr, 0, -1, true, {" " .. text .. " "})
6276 end
6377
6478 local close = function()
6579 vim.fn.timer_start(delayed_close_time, function()
66- if self.winnr ~= nil then
80+ if vim.api.nvim_win_is_valid(self.winnr) == true then
6781 vim.api.nvim_win_close(self.winnr, true)
6882 num_window = num_window - 1
6983 self.winnr = nil