From 7d484d8bfd61306682b1e1da203edfd2cd482b92 Mon Sep 17 00:00:00 2001 From: hrsh7th Date: Sat, 16 Oct 2021 12:05:56 +0900 Subject: [PATCH] Fix same name property Fix #354 --- lua/cmp/view/native_entries_view.lua | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/lua/cmp/view/native_entries_view.lua b/lua/cmp/view/native_entries_view.lua index 29c532b..caa11d1 100644 --- a/lua/cmp/view/native_entries_view.lua +++ b/lua/cmp/view/native_entries_view.lua @@ -9,7 +9,7 @@ local misc = require('cmp.utils.misc') ---@field private offset number ---@field private items vim.CompletedItem ---@field private entries cmp.Entry[] ----@field private preselect number +---@field private preselect_index number ---@field public event cmp.Event local native_entries_view = {} @@ -19,7 +19,7 @@ native_entries_view.new = function() self.offset = -1 self.items = {} self.entries = {} - self.preselect = 0 + self.preselect_index = 0 autocmd.subscribe('CompleteChanged', function() self.event:emit('change') end) @@ -36,12 +36,12 @@ end native_entries_view.redraw = function(self) if #self.entries > 0 and self.offset <= vim.api.nvim_win_get_cursor(0)[2] + 1 then local completeopt = vim.o.completeopt - vim.o.completeopt = self.preselect == 1 and 'menu,menuone,noinsert' or config.get().completion.completeopt + vim.o.completeopt = self.preselect_index == 1 and 'menu,menuone,noinsert' or config.get().completion.completeopt vim.fn.complete(self.offset, self.items) vim.o.completeopt = completeopt - if self.preselect > 1 and config.get().preselect == types.cmp.PreselectMode.Item then - self:preselect(self.preselect) + if self.preselect_index > 1 and config.get().preselect == types.cmp.PreselectMode.Item then + self:preselect(self.preselect_index) end end end @@ -50,22 +50,22 @@ native_entries_view.open = function(self, offset, entries) local dedup = {} local items = {} local dedup_entries = {} - local preselect = 0 + local preselect_index = 0 for _, e in ipairs(entries) do local item = e:get_vim_item(offset) if item.dup == 1 or not dedup[item.abbr] then dedup[item.abbr] = true table.insert(items, item) table.insert(dedup_entries, e) - if preselect == 0 and e.completion_item.preselect then - preselect = #dedup_entries + if preselect_index == 0 and e.completion_item.preselect then + preselect_index = #dedup_entries end end end self.offset = offset self.items = items self.entries = dedup_entries - self.preselect = preselect + self.preselect_index = preselect_index self:redraw() end @@ -76,7 +76,7 @@ native_entries_view.close = function(self) self.offset = -1 self.entries = {} self.items = {} - self.preselect = 0 + self.preselect_index = 0 end native_entries_view.abort = function(_)