🐛 fix(vscode): 代码阅读预览跳到还没打开的文件时停在文件顶上不再发生:新开的预览注释里有仓库图片时,问图片才把仓库根加进 webview 能读的目录,改了选项 VS Code 重新加载页面,第二次 ready 发的文档不带要滚到的那处;页面能读的目录(页面资源、问答图片、这一页仓库链接的各个根及其真实位置)改在装页面之前一次定好,之后不再改选项,LinkBase 带上它算得出的根
This commit is contained in:
1 parent
95fc539c3a
commit
ad35898716
3 files changed
+66
-35
No files matched your search
@@ -43,8 +43,11 @@ export function featureFolders(): NamedFolder[] {
|
||||
return (workspace.workspaceFolders ?? []).map(folder => ({ name: folder.name, path: folder.uri.fsPath }))
|
||||
}
|
||||
|
||||
/** 把页面上一条仓库链接的路径换成磁盘上的位置;算不出来的没有。 */
|
||||
export type LinkBase = (rel: string) => RepoPlace | undefined
|
||||
/** 一页上的仓库链接从哪儿算:`place` 把一条链接的路径换成磁盘上的位置,算不出来的没有;算出来的位置都在 `roots` 这几个根下面。 */
|
||||
export interface LinkBase {
|
||||
place: (rel: string) => RepoPlace | undefined
|
||||
roots: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览这一页上仓库链接的路径从哪儿算:功能对话页从这个功能找代码用的工作区文件夹算(见 [featureFolders]、[folderLinkPlace]),
|
||||
@@ -53,10 +56,10 @@ export type LinkBase = (rel: string) => RepoPlace | undefined
|
||||
export async function linkBaseOf(uri: Uri): Promise<LinkBase> {
|
||||
if (featureIdOf(uri) !== undefined) {
|
||||
const folders = featureFolders()
|
||||
return rel => folderLinkPlace(folders, rel)
|
||||
return { place: rel => folderLinkPlace(folders, rel), roots: folders.map(folder => folder.path) }
|
||||
}
|
||||
const root = await repoRootOf(uri.fsPath)
|
||||
return rel => root === undefined ? undefined : { root, rel }
|
||||
return root === undefined ? { place: () => undefined, roots: [] } : { place: rel => ({ root, rel }), roots: [root] }
|
||||
}
|
||||
|
||||
export function pathPreviewUri(target: Uri, kind: PathSubject): Uri {
|
||||
|
||||
Reference in new issue
Block a user