Skip to content

Commit

Permalink
添加工具提示虚拟链接,防止消失
Browse files Browse the repository at this point in the history
  • Loading branch information
geezmolycos committed May 8, 2023
1 parent efd5e75 commit e46113b
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"name": "Run Extension",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "D:\\scoop\\apps\\vscode\\current\\Code.exe",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}",
"${workspaceFolder}/comparison.md"
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ All notable changes to the "vscode-hanzi-counter" extension will be documented i
- 日本语较准确的「原稿用紙換算」
- 发布到open vsx上

## [1.5.2] - 2023-05-08

- 在工具提示里面添加了虚拟的链接,供 VS Code 检测,以使鼠标离开工具提示时不消失 (fix #2)
- 设置了状态栏项目的 `accessibilityInformation` 属性,方便屏幕阅读器阅读

## [1.5.1] - 2023-03-29

- CJK 字符现在使用了分段器
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"regex"
],
"description": "多功能文档字数统计,支持中文、日文、朝鲜/韩文,支持选区统计,点击即可高亮,也可用正则表达式自定义要统计的内容。\n\n中国語/日本語/朝鮮/韓国語文字数計算ツール。중국어/일본어/한국어/조선어 세기 도구.\n\nCustomizable word counter with great support of Chinese characters (Hanzi), Japanese and Korean. Supports count in selection. Supports highlighting. Use custom regexes to match any character type you want.",
"version": "1.5.1",
"version": "1.5.2",
"publisher": "geezmolycos",
"engines": {
"vscode": "^1.74.0"
Expand Down
7 changes: 6 additions & 1 deletion src/counter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class Counter {
? vscode.StatusBarAlignment.Left : vscode.StatusBarAlignment.Right,
configuration.get('vscode-hanzi-counter.statusBar.priority') ?? 105); // default left of text attributes(ln, col, spaces, encoding, etc)
this._statusBarItem.name = 'Hanzi Counter';
this._statusBarItem.accessibilityInformation = {label: 'Hanzi Counter'};

// create decoration type
this._decorationTypes = [
Expand Down Expand Up @@ -129,9 +130,13 @@ export class Counter {
public updateStatusBarItem(text?: string, tooltipText?: string){
if (text){
this._statusBarItem.text = text;
this._statusBarItem.accessibilityInformation = {label: text};
}
if (tooltipText){
let ms = new vscode.MarkdownString(tooltipText);
let ms = new vscode.MarkdownString('<!--[Fake link](#)-->\n' + tooltipText);
// The "Fake link" part is to let vscode think it contains a markdown link
// so that the tooltip pop-up will stay open on mouse leave
// Reference: https://github.com/microsoft/vscode/blob/d1aa00acef8b2cfa88621c448b8fd8cd034f60a9/src/vs/workbench/services/hover/browser/hoverWidget.ts#L205
ms.isTrusted = true;
ms.supportHtml = true;
ms.supportThemeIcons = true;
Expand Down

0 comments on commit e46113b

Please sign in to comment.