Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复状态栏点击时的弹窗失效 #72

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 14 additions & 3 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,15 @@ function activate(context: ExtensionContext) {
// TODO: 避免重复查询(状态框查询一次即可?)
let 文本 = 取选中文本();
if (文本) {
let 显示 = 显示字段信息(查询词条(文本));
window.showInformationMessage(显示词条(显示, 1000));
let 显示 = 显示字段信息(查询词条(文本)) as unknown as {
value:string
}
if(typeof 显示 === 'string'){
window.showInformationMessage(显示词条(显示, 1000));
} else {
显示.value = 显示.value.replace(/ /g, ' ').replace(/\s+/g, ' ').trim()
window.showInformationMessage(显示词条(显示.value, 1000));
}
}
}));

Expand Down Expand Up @@ -107,7 +114,11 @@ function 显示字段信息(查字段结果: 模型.字段释义): string {
if (查字段结果.各词.length == 1) {
return 取单词条信息(查字段结果.各词[0], true);
} else {
const 翻译结果 = 查字段结果.各词.map(单词结果 => 取单词条信息(单词结果, true, false))
const 验证是否为单独字母 = /^[a-zA-Z]$/;
const 翻译结果 = 查字段结果.各词.map(单词结果 => {
if(单词结果.词.length ===1 && 验证是否为单独字母.test(单词结果.词)) return
return 取单词条信息(单词结果, true, false)
}).filter(单词结果 => 单词结果)
const 结果模版 = new vscode.MarkdownString();
翻译结果.forEach(单词结果 => 结果模版.appendText(`${单词结果}\n`));
return 结果模版
Expand Down