Neovim plugin improving access to clipboard history (mirror)

fix: call `ensure_initialized` in yankbank api functions (#27)

authored by

Patrick Dewey and committed by
GitHub
8c912aee 0d97b474

+6
+6
lua/yankbank/api.lua
··· 6 6 ---@param i integer 7 7 ---@return table 8 8 function M.get_entry(i) 9 + require("yankbank").ensure_initialized() 9 10 return { 10 11 yank_text = state.get_yanks()[i], 11 12 reg_type = state.get_reg_types()[i], ··· 15 16 --- get a table containing all yankbank entries 16 17 ---@return table 17 18 function M.get_all() 19 + require("yankbank").ensure_initialized() 18 20 local out = {} 19 21 local yanks = state.get_yanks() 20 22 local reg_types = state.get_reg_types() ··· 32 34 ---@param reg_type string register type "v", "V", or "^V" (visual, v-line, v-block respectively) 33 35 ---@param pin integer|boolean? 34 36 function M.add_entry(yank_text, reg_type, pin) 37 + require("yankbank").ensure_initialized() 35 38 require("yankbank.clipboard").add_yank(yank_text, reg_type, pin) 36 39 end 37 40 38 41 --- remove entry from yankbank by index 39 42 ---@param i integer index to remove 40 43 function M.remove_entry(i) 44 + require("yankbank").ensure_initialized() 41 45 local yanks = state.get_yanks() 42 46 local reg_types = state.get_reg_types() 43 47 local yank_text = table.remove(yanks, i) ··· 57 61 --- 58 62 ---@param i integer index to pin 59 63 function M.pin_entry(i) 64 + require("yankbank").ensure_initialized() 60 65 local pins = state.get_pins() 61 66 if i > #pins then 62 67 return ··· 78 83 --- 79 84 ---@param i integer index to unpin 80 85 function M.unpin_entry(i) 86 + require("yankbank").ensure_initialized() 81 87 local pins = state.get_pins() 82 88 if i > #pins then 83 89 return