Skip to content

Commit dddda22

Browse files
committed
feat: rename open-explorer-entry command to open-entry and update related references
1 parent c405b74 commit dddda22

3 files changed

Lines changed: 20 additions & 28 deletions

File tree

package.json

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,10 @@
4646
"icon": "$(refresh)"
4747
},
4848
{
49-
"command": "ucd.open-explorer-entry",
50-
"title": "Open UCD Explorer Entry",
51-
"category": "UCD"
49+
"command": "ucd.open-entry",
50+
"title": "Open UCD Entry",
51+
"category": "UCD",
52+
"icon": "$(file-text)"
5253
}
5354
],
5455
"configuration": {
@@ -111,7 +112,7 @@
111112
"group": "navigation"
112113
},
113114
{
114-
"command": "ucd.open-explorer-entry",
115+
"command": "ucd.open-entry",
115116
"when": "viewItem == ucd:explorer-file || viewItem == ucd:explorer-folder || viewItem == ucd:version-folder",
116117
"group": "navigation"
117118
}
@@ -120,16 +121,10 @@
120121
{
121122
"command": "ucd.visualize-file",
122123
"group": "navigation",
123-
"when": "resourceScheme == ucd"
124+
"when": "editorLangId == ucd"
124125
}
125126
]
126127
},
127-
"viewsWelcome": [
128-
{
129-
"view": "ucd-explorer",
130-
"contents": "# Welcome to UCD Explorer\n\nThis extension allows you to browse and visualize Unicode Character Database (UCD) files. Use the commands in the command palette or the context menu to interact with the files."
131-
}
132-
],
133128
"languages": [
134129
{
135130
"id": "ucd",

src/extension.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,37 @@ import { useUCDExplorer } from "./views/ucd-explorer";
1111

1212
const { activate, deactivate } = defineExtension(async () => {
1313
useCommand(Meta.commands.browseUcdFiles, async () => {
14-
logger.info("Browsing UCD files...");
15-
const store = useUCDStore();
16-
const data = await store.value?.getFilePaths("16.0.0");
17-
logger.info(`Fetched files for version 16.0.0: ${JSON.stringify(data, null, 2)}`);
14+
executeCommand("ucd:explorer.focus");
1815
});
1916

2017
useCommand(Meta.commands.refreshExplorer, async () => {
2118
logger.info("Refreshing UCD Explorer...");
2219
logger.info("UCD Explorer refreshed.");
20+
21+
const store = useUCDStore();
22+
if (!store.value) {
23+
logger.error("UCD Store is not initialized.");
24+
return;
25+
}
26+
27+
store.refresh();
2328
});
2429

2530
useCommand(Meta.commands.visualizeFile, () => {
26-
logger.info("Visualizing UCD file...");
27-
// require that current editor is a UCD File
28-
const editor = useActiveTextEditor();
29-
logger.info("Current active editor:", JSON.stringify(editor.value, null, 2));
30-
useEditorDecorations(editor, {
31-
backgroundColor: "red",
32-
}, () => [
33-
editor.value?.visibleRanges[0] || new Range(0, 0, 20, 20),
34-
]);
31+
window.showErrorMessage("This command is not implemented yet.");
3532
});
3633

37-
useCommand(Meta.commands.openExplorerEntry, async (versionOrTreeView: string | TreeViewNode, filePath?: string) => {
34+
useCommand(Meta.commands.openEntry, async (versionOrTreeView: string | TreeViewNode, filePath?: string) => {
3835
if (versionOrTreeView == null) {
39-
logger.error("No entry provided to openExplorerEntry command.");
36+
logger.error("No entry provided to openEntry command.");
4037
return;
4138
}
4239

4340
if (typeof versionOrTreeView === "object" && "treeItem" in versionOrTreeView) {
4441
const treeView = versionOrTreeView;
4542

4643
if (!treeView.treeItem || !(treeView.treeItem as UCDTreeItem).__ucd) {
47-
logger.error("Invalid entry provided to openExplorerEntry command.");
44+
logger.error("Invalid entry provided to openEntry command.");
4845
return;
4946
}
5047

src/lib/files.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ function mapEntryToTreeNode(version: string, entry: UnicodeVersionFile, parentPa
2020
...(!hasChildren
2121
? {
2222
command: {
23-
command: Meta.commands.openExplorerEntry,
23+
command: Meta.commands.openEntry,
2424
title: "Open UCD Data File",
2525
arguments: [
2626
version,

0 commit comments

Comments
 (0)