Skip to content

Commit d8928ac

Browse files
authored
Merge pull request #235 from cnblogs/fix-undefined-post-id
fix: undefined post id
2 parents d1e4ce5 + 21efa8d commit d8928ac

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/cmd/open/os-open-local-post-file.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,15 @@ import { Uri } from 'vscode'
22
import { execCmd } from '@/infra/cmd'
33
import { Post } from '@/model/post'
44
import { PostFileMapManager } from '@/service/post/post-file-map'
5+
import { PostTreeItem } from '@/tree-view/model/post-tree-item'
56

6-
export function osOpenLocalPostFile(post?: Post) {
7-
if (post === undefined) return
7+
export function osOpenLocalPostFile(post?: Post | PostTreeItem) {
8+
if (post === undefined) {
9+
console.error('post is undefined in osOpenLocalPostFile')
10+
return
11+
}
812

13+
post = post instanceof PostTreeItem ? post.post : post
914
const postFilePath = PostFileMapManager.getFilePath(post.id)
1015
if (postFilePath === undefined) return
1116

0 commit comments

Comments
 (0)