🐛 fix(vscode): 代码阅读注释里的链接指到别的文件时用预览打开,和 ⌘ 点击跳到定义走同一条路
This commit is contained in:
1 parent
e04a90c877
commit
bc7380c716
9 files changed
+123
-72
No files matched your search
@@ -1,20 +1,19 @@
|
||||
/** 一处定义。uri 是 Uri.toString(),用来和当前文件比、去重;supported:目标文件的语言有代码阅读。 */
|
||||
/** 一处定义。uri 是 Uri.toString(),用来和当前文件比、去重。 */
|
||||
export interface DefinitionTarget {
|
||||
uri: string
|
||||
line: number
|
||||
character: number
|
||||
supported: boolean
|
||||
}
|
||||
|
||||
/**
|
||||
* ⌘ / Ctrl + 点击查到定义之后怎么做:
|
||||
* none 不动;pick 让用户从几处里挑一处,挑好的那处再交给 definitionAction 决定;
|
||||
* here 定义就在当前文件,预览原地滚过去;preview 用代码阅读预览打开目标文件;text 目标语言没有代码阅读,用普通文本编辑器打开。
|
||||
* here 定义就在当前文件,预览原地滚过去;elsewhere 在另一个文件,用哪种编辑器打开见 openTarget.ts 的 openingFor。
|
||||
*/
|
||||
export type DefinitionAction<T extends DefinitionTarget>
|
||||
= | { kind: 'none' }
|
||||
| { kind: 'pick', targets: T[] }
|
||||
| { kind: 'here' | 'preview' | 'text', target: T }
|
||||
| { kind: 'here' | 'elsewhere', target: T }
|
||||
|
||||
/** 定义提供者查到的几处(可能重复)→ 怎么跳。current 是当前文件的 Uri.toString()。 */
|
||||
export function definitionAction<T extends DefinitionTarget>(targets: readonly T[], current: string): DefinitionAction<T> {
|
||||
@@ -25,7 +24,5 @@ export function definitionAction<T extends DefinitionTarget>(targets: readonly T
|
||||
if (unique.length > 1)
|
||||
return { kind: 'pick', targets: unique }
|
||||
const [target] = unique
|
||||
if (target.uri === current)
|
||||
return { kind: 'here', target }
|
||||
return { kind: target.supported ? 'preview' : 'text', target }
|
||||
return { kind: target.uri === current ? 'here' : 'elsewhere', target }
|
||||
}
|
||||
Reference in new issue
Block a user