No longer store autocomplete options in config

Plugins should not store private stuff in core.config because this
latter can be reloaded due to user changing preferences.
This commit is contained in:
Francesco Abbate 2021-12-28 12:25:48 +01:00
parent 1f0785b73f
commit 0f1b84040d
1 changed files with 6 additions and 6 deletions

View File

@ -10,7 +10,7 @@ local RootView = require "core.rootview"
local DocView = require "core.docview"
local Doc = require "core.doc"
config.plugins.autocomplete = {
local autocomplete_options = {
-- Amount of characters that need to be written for autocomplete
min_len = 3,
-- The max amount of visible items
@ -192,7 +192,7 @@ local function update_suggestions()
-- fuzzy match, remove duplicates and store
items = common.fuzzy_match(items, partial)
local j = 1
for i = 1, config.plugins.autocomplete.max_suggestions do
for i = 1, autocomplete_options.max_suggestions do
suggestions[i] = items[j]
while items[j] and items[i].text == items[j].text do
items[i].info = items[i].info or items[j].info
@ -235,7 +235,7 @@ local function get_suggestions_rect(av)
max_width = math.max(max_width, w)
end
local ah = config.plugins.autocomplete.max_height
local ah = autocomplete_options.max_height
local max_items = #suggestions
if max_items > ah then
@ -294,7 +294,7 @@ local function draw_suggestions_box(av)
return
end
local ah = config.plugins.autocomplete.max_height
local ah = autocomplete_options.max_height
-- draw background rect
local rx, ry, rw, rh = get_suggestions_rect(av)
@ -355,7 +355,7 @@ local function show_autocomplete()
-- update partial symbol and suggestions
partial = get_partial_symbol()
if #partial >= config.plugins.autocomplete.min_len or triggered_manually then
if #partial >= autocomplete_options.min_len or triggered_manually then
update_suggestions()
if not triggered_manually then
@ -469,7 +469,7 @@ function autocomplete.complete(completions, on_close)
end
function autocomplete.can_complete()
if #partial >= config.plugins.autocomplete.min_len then
if #partial >= autocomplete_options.min_len then
return true
end
return false