Neovim plugin improving access to clipboard history (mirror)
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

reset file.lua to original branch state

+23 -11
+23 -11
lua/yankbank/persistence/file.lua
··· 50 50 ---@param line string: line from file being checked 51 51 ---@return table|nil 52 52 local function check_for_entry(line) 53 - local i, l, rt = string.match(line, "<YANKBANK_ENTRY:(%d+),(%d+),(%a+)>") 53 + local i, l, rt = 54 + string.match(line, "<YANKBANK_ENTRY:(%d+),(%d+),(%a+)>") 54 55 if i then 55 56 return { 56 57 index = tonumber(i), ··· 86 87 local lines = {} 87 88 for line in f:lines() do 88 89 if 89 - string.match(line, "<YANKBANK_ENTRY:" .. n_entries .. ",%d+,%a+>") 90 + string.match( 91 + line, 92 + "<YANKBANK_ENTRY:" .. n_entries .. ",%d+,%a+>" 93 + ) 90 94 then 91 95 n_entries = n_entries - 1 92 96 lines[1] = "<YANKBANK_LIST:" .. n_entries .. ">\n" ··· 138 142 139 143 -- write entry header 140 144 -- FIX: #entry doesn't match number of lines when it is string (number of chars instead of lines) 141 - f:write("<YANKBANK_ENTRY:1," .. #entry .. "," .. reg_type .. ">\n") 145 + f:write( 146 + "<YANKBANK_ENTRY:1," 147 + .. #entry 148 + .. "," 149 + .. reg_type 150 + .. ">\n" 151 + ) 142 152 -- write entry 143 153 if type(entry) == "string" then 144 154 f:write(entry) ··· 151 161 152 162 -- write remaining lines 153 163 for i = 2, #lines do 154 - local n, l, rt = 155 - string.match(lines[i], "<YANKBANK_ENTRY:(%d+),(%d+),(%a+)>") 164 + local n, l, rt = string.match( 165 + lines[i], 166 + "<YANKBANK_ENTRY:(%d+),(%d+),(%a+)>" 167 + ) 156 168 if n then 157 169 lines[i] = "<YANKBANK_ENTRY:" 158 - .. n + 1 159 - .. "," 160 - .. l 161 - .. "," 162 - .. rt 163 - .. ">" 170 + .. n + 1 171 + .. "," 172 + .. l 173 + .. "," 174 + .. rt 175 + .. ">" 164 176 end 165 177 -- TODO: check headers 166 178 f:write(lines[i] .. "\n")