From 2baf5085b2086f3e21eb911ef69c15aa53d7a55e Mon Sep 17 00:00:00 2001 From: hbybyyang <2451759073@qq.com> Date: Thu, 4 Feb 2021 00:17:26 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E5=8F=91=E7=8E=B0=E8=AF=8D=E7=9A=84=E8=AE=BE=E7=BD=AE=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + package.json | 13 +++++++++++++ ...\241\245\345\205\250\345\256\236\347\216\260.js" | 11 +++++++---- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f3fdc51..bf7744f 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 未发布 - 改进: [调用输入法接口出错信息完善](https://gitee.com/Program-in-Chinese/vscode_Chinese_Input_Assistant/issues/I359EF) +- 改进: [增加关闭发现词的设置项](https://gitee.com/Program-in-Chinese/vscode_Chinese_Input_Assistant/issues/I2DPEL) ## 1.3.5 diff --git a/package.json b/package.json index c18f182..909ef8e 100755 --- a/package.json +++ b/package.json @@ -65,6 +65,19 @@ "markdown文件不触发补全", "markdown文件触发补全" ] + }, + "ChineseInputAssistant.useFileWord": { + "type": "string", + "description": "是否分析当前文档的词作为补全项", + "default": "yes", + "enum": [ + "yes", + "no" + ], + "enumDescriptions": [ + "是", + "否" + ] } } }, diff --git "a/\350\241\245\345\205\250\345\256\236\347\216\260.js" "b/\350\241\245\345\205\250\345\256\236\347\216\260.js" index f6bc066..4107d74 100755 --- "a/\350\241\245\345\205\250\345\256\236\347\216\260.js" +++ "b/\350\241\245\345\205\250\345\256\236\347\216\260.js" @@ -36,6 +36,7 @@ async function provideCompletionItems(document, position, token, context) { 用户配置.使用输入法 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("InputMethod") 用户配置.markdown补全 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("markdownUse") 用户配置.提示方式 = vscode.workspace.getConfiguration('中文代码快速补全').get("提示方式") + 用户配置.是否分析当前文档的词作为补全项 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("是否分析当前文档的词作为补全项") // log('用户配置', 用户配置) if (document.languageId == 'markdown' && !(用户配置.markdown补全 == 'yes')) return [] @@ -66,10 +67,12 @@ async function provideCompletionItems(document, position, token, context) { // 补全项 = 补全项.concat(文档字段提供程序) // log('文档字段提供程序', 文档字段提供程序.map(a => a.label)) - var 文档字段 = R.compose(R.filter(包含中文), 查找字段)(document.getText()) - 文档字段 = 文档字段.map(a => new vscode.CompletionItem(a, vscode.CompletionItemKind.Text)) - 补全项 = 补全项.concat(文档字段) - // log('文档字段', 文档字段.map(a => a.label)) + if (是否分析当前文档的词作为补全项 == 'yes') { + var 文档字段 = R.compose(R.filter(包含中文), 查找字段)(document.getText()) + 文档字段 = 文档字段.map(a => new vscode.CompletionItem(a, vscode.CompletionItemKind.Text)) + 补全项 = 补全项.concat(文档字段) + // log('文档字段', 文档字段.map(a => a.label)) + } if (用户配置.使用输入法 != 'no') { // 如果分段输入一个词组,例如“多重笛卡尔积”,输入顺序是:先输入“多重”,再输入“笛卡尔积”。 -- Gitee From 300fefc1248db6ede12d13ec90c4a13606146e30 Mon Sep 17 00:00:00 2001 From: hbybyyang <2451759073@qq.com> Date: Thu, 4 Feb 2021 00:29:29 +0800 Subject: [PATCH 2/2] debug --- package.json | 13 +++++++++++++ ...41\245\345\205\250\345\256\236\347\216\260.js" | 15 +++++++++------ 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 909ef8e..07b731c 100755 --- a/package.json +++ b/package.json @@ -66,6 +66,19 @@ "markdown文件触发补全" ] }, + "ChineseInputAssistant.useCompletionItem": { + "type": "string", + "description": "是否分析vscode提供的补全项", + "default": "yes", + "enum": [ + "yes", + "no" + ], + "enumDescriptions": [ + "是", + "否" + ] + }, "ChineseInputAssistant.useFileWord": { "type": "string", "description": "是否分析当前文档的词作为补全项", diff --git "a/\350\241\245\345\205\250\345\256\236\347\216\260.js" "b/\350\241\245\345\205\250\345\256\236\347\216\260.js" index 4107d74..2053f8a 100755 --- "a/\350\241\245\345\205\250\345\256\236\347\216\260.js" +++ "b/\350\241\245\345\205\250\345\256\236\347\216\260.js" @@ -36,7 +36,8 @@ async function provideCompletionItems(document, position, token, context) { 用户配置.使用输入法 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("InputMethod") 用户配置.markdown补全 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("markdownUse") 用户配置.提示方式 = vscode.workspace.getConfiguration('中文代码快速补全').get("提示方式") - 用户配置.是否分析当前文档的词作为补全项 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("是否分析当前文档的词作为补全项") + 用户配置.是否分析vscode提供的补全项 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("useCompletionItem") + 用户配置.是否分析当前文档的词作为补全项 = vscode.workspace.getConfiguration('ChineseInputAssistant').get("useFileWord") // log('用户配置', 用户配置) if (document.languageId == 'markdown' && !(用户配置.markdown补全 == 'yes')) return [] @@ -54,10 +55,12 @@ async function provideCompletionItems(document, position, token, context) { var 补全项 = [] - var 补全项提供器 = await vscode.commands.executeCommand('vscode.executeCompletionItemProvider', document.uri, position) - 补全项提供器 = 补全项提供器.items - 补全项 = 补全项.concat(补全项提供器) - // log('补全项提供器', 补全项提供器.map(a => a.label)) + if (用户配置.是否分析vscode提供的补全项 == 'yes') { + var 补全项提供器 = await vscode.commands.executeCommand('vscode.executeCompletionItemProvider', document.uri, position) + 补全项提供器 = 补全项提供器.items + 补全项 = 补全项.concat(补全项提供器) + // log('补全项提供器', 补全项提供器.map(a => a.label)) + } 防递归锁 = false @@ -67,7 +70,7 @@ async function provideCompletionItems(document, position, token, context) { // 补全项 = 补全项.concat(文档字段提供程序) // log('文档字段提供程序', 文档字段提供程序.map(a => a.label)) - if (是否分析当前文档的词作为补全项 == 'yes') { + if (用户配置.是否分析当前文档的词作为补全项 == 'yes') { var 文档字段 = R.compose(R.filter(包含中文), 查找字段)(document.getText()) 文档字段 = 文档字段.map(a => new vscode.CompletionItem(a, vscode.CompletionItemKind.Text)) 补全项 = 补全项.concat(文档字段) -- Gitee