From 908feedce35b056c38fab57fd4e32727b117479c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 30 Apr 2021 15:54:20 +0800 Subject: resolve #507 new setting `hover.enumsLimit` --- script/config.lua | 1 + script/core/guide.lua | 11 ++++++++++- script/proto/define.lua | 3 --- 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'script') diff --git a/script/config.lua b/script/config.lua index a133cf1c..8bc05b98 100644 --- a/script/config.lua +++ b/script/config.lua @@ -176,6 +176,7 @@ local ConfigTemplate = { viewNumber = {true, Boolean}, fieldInfer = {3000, Integer}, previewFields = {100, Integer}, + enumsLimit = {5, Integer}, }, color = { mode = {'Semantic', String}, diff --git a/script/core/guide.lua b/script/core/guide.lua index b80a3628..367b91e2 100644 --- a/script/core/guide.lua +++ b/script/core/guide.lua @@ -1,4 +1,6 @@ local util = require 'utility' +local config = require 'config' +local lang = require 'language' local error = error local type = type local next = next @@ -3396,7 +3398,14 @@ function m.mergeTypes(types) end end) - return tableConcat(results, '|') + local enumsLimit = config.config.hover.enumsLimit + if #results > enumsLimit then + return tableConcat(results, '|', 1, enumsLimit) + .. lang.script('HOVER_MORE_ENUMS', #results - enumsLimit) + else + return tableConcat(results, '|') + end + end function m.getClassExtends(class) diff --git a/script/proto/define.lua b/script/proto/define.lua index 15e434de..abfaa9b0 100644 --- a/script/proto/define.lua +++ b/script/proto/define.lua @@ -1,6 +1,3 @@ -local guide = require 'core.guide' -local util = require 'utility' - local m = {} ---@alias location table -- cgit v1.2.3