Skip to content

Commit befd939

Browse files
JamesCamelYukaii
authored andcommitted
Fix tab title with '.'
1 parent 28a4a49 commit befd939

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/commands/treeView.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ export async function registerTreeViewCommands(context: vscode.ExtensionContext)
4343
const content = await API.exportString(noteId, ExportType.MD);
4444
if (!checkNoteExist(content)) { return; }
4545

46-
const fileName = editor.document.fileName.split('.')[0];
46+
const lastIndex = editor.document.fileName.lastIndexOf('.');
47+
const fileName = editor.document.fileName.slice(0, lastIndex+1);
4748
const uri = vscode.Uri.parse(`hackmd:${fileName}.md#${noteId}`);
4849
vscode.commands.executeCommand('markdown.showPreview', uri);
4950
}
@@ -54,6 +55,7 @@ export async function registerTreeViewCommands(context: vscode.ExtensionContext)
5455
const content = await API.exportString(noteNode.noteId, ExportType.MD);
5556
if (!checkNoteExist(content)) { return; }
5657

58+
console.log(noteNode.label);
5759
const uri = vscode.Uri.parse(`hackmd:${noteNode.label}.md#${noteNode.noteId}`);
5860
const doc = await vscode.workspace.openTextDocument(uri);
5961
await vscode.window.showTextDocument(doc, { preview: false });
@@ -69,7 +71,8 @@ export async function registerTreeViewCommands(context: vscode.ExtensionContext)
6971
const content = await API.exportString(noteId, ExportType.MD);
7072
if (!checkNoteExist(content)) { return; }
7173

72-
const fileName = editor.document.fileName.split('.')[0];
74+
const lastIndex = editor.document.fileName.lastIndexOf('.');
75+
const fileName = editor.document.fileName.slice(0, lastIndex+1);
7376
const uri = vscode.Uri.parse(`hackmd:${fileName}.md#${noteId}`);
7477
const doc = await vscode.workspace.openTextDocument(uri);
7578
await vscode.window.showTextDocument(doc, { preview: false });

0 commit comments

Comments
 (0)