From 0959ed7ca7652cc1e209ec47ddb46a03357bd8c9 Mon Sep 17 00:00:00 2001 From: Shougo Matsushita Date: Fri, 5 Jul 2024 13:28:23 +0900 Subject: [PATCH] Add maxManualCompleteLength and minManualCompleteLength --- denops/ddc/base/source.ts | 2 ++ denops/ddc/ddc.ts | 8 +++++--- denops/ddc/types.ts | 2 ++ doc/ddc.txt | 38 ++++++++++++++++++++++---------------- 4 files changed, 31 insertions(+), 19 deletions(-) diff --git a/denops/ddc/base/source.ts b/denops/ddc/base/source.ts index c1b559e..bda8db2 100644 --- a/denops/ddc/base/source.ts +++ b/denops/ddc/base/source.ts @@ -149,9 +149,11 @@ export function defaultSourceOptions(): SourceOptions { matcherKey: "", matchers: [], maxAutoCompleteLength: 80, + maxManualCompleteLength: 80, maxItems: 500, maxKeywordLength: 0, minAutoCompleteLength: 2, + minManualCompleteLength: 1, minKeywordLength: 0, preview: true, replaceSourceInputPattern: "", diff --git a/denops/ddc/ddc.ts b/denops/ddc/ddc.ts index 0bdf80e..018dd81 100644 --- a/denops/ddc/ddc.ts +++ b/denops/ddc/ddc.ts @@ -159,9 +159,11 @@ export class Ddc { ? this.#prevResults[s.name] : null; - const invalidCompleteLength = - completeStr.length < o.minAutoCompleteLength || - completeStr.length > o.maxAutoCompleteLength; + const invalidCompleteLength = context.event === "Manual" + ? (completeStr.length < o.minManualCompleteLength || + completeStr.length > o.maxManualCompleteLength) + : (completeStr.length < o.minAutoCompleteLength || + completeStr.length > o.maxAutoCompleteLength); const triggerForIncomplete = (checkPrevResult?.isIncomplete ?? false) && context.lineNr === checkPrevResult?.lineNr && diff --git a/denops/ddc/types.ts b/denops/ddc/types.ts index e27f5c5..4512818 100644 --- a/denops/ddc/types.ts +++ b/denops/ddc/types.ts @@ -85,9 +85,11 @@ export type SourceOptions = { matcherKey: string; matchers: UserFilter[]; maxAutoCompleteLength: number; + maxManualCompleteLength: number; maxItems: number; maxKeywordLength: number; minAutoCompleteLength: number; + minManualCompleteLength: number; minKeywordLength: number; preview: boolean; sorters: UserFilter[]; diff --git a/doc/ddc.txt b/doc/ddc.txt index a6ded02..2416b1d 100644 --- a/doc/ddc.txt +++ b/doc/ddc.txt @@ -754,20 +754,6 @@ mark (string) Default: "" - *ddc-source-option-maxAutoCompleteLength* -maxAutoCompleteLength (number) - Ignored length of keyword for auto completion. - It is useful to edit BASE64 files. - - Default: 80 - - *ddc-source-option-maxItems* -maxItems (number) - If there are more items than this value, ddc will ignore the - filtering. - - Default: 500 - *ddc-source-option-matcherKey* matcherKey (string) Matcher compare key instead of "word". @@ -792,10 +778,11 @@ matchers (string[]) *ddc-source-option-maxAutoCompleteLength* maxAutoCompleteLength (number) - The mamimum length of keyword required for auto completion. + Ignored length of keyword for auto completion. + It is useful to edit BASE64 files. NOTE: It does not work for manual completion. - Default: 2 + Default: 80 *ddc-source-option-maxKeywordLength* maxKeywordLength (number) @@ -804,6 +791,19 @@ maxKeywordLength (number) Default: 0 + *ddc-source-option-maxItems* +maxItems (number) + If there are more items than this value, ddc will ignore the + filtering. + + Default: 500 + + *ddc-source-option-maxManualCompleteLength* +maxManualCompleteLength (number) + The mamimum length of keyword required for manual completion. + + Default: 80 + *ddc-source-option-minAutoCompleteLength* minAutoCompleteLength (number) The minimum length of keyword required for auto completion. @@ -811,6 +811,12 @@ minAutoCompleteLength (number) Default: 2 + *ddc-source-option-minManualCompleteLength* +minManualCompleteLength (number) + The minimum length of keyword required for manual completion. + + Default: 1 + *ddc-source-option-minKeywordLength* minKeywordLength (number) The minimum word of length for items.