Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
059f2cf4
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
059f2cf4
编写于
4月 30, 2021
作者:
L
Logan Ramos
提交者:
GitHub
4月 30, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Ensure that notebook cell URIs work (#122746)
上级
2285f879
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
58 addition
and
36 deletion
+58
-36
src/vs/base/test/common/glob.test.ts
src/vs/base/test/common/glob.test.ts
+6
-0
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
...workbench/contrib/notebook/browser/notebookServiceImpl.ts
+47
-33
src/vs/workbench/services/editor/browser/editorOverrideService.ts
...orkbench/services/editor/browser/editorOverrideService.ts
+4
-2
src/vs/workbench/services/editor/common/editorOverrideService.ts
...workbench/services/editor/common/editorOverrideService.ts
+1
-1
未找到文件。
src/vs/base/test/common/glob.test.ts
浏览文件 @
059f2cf4
...
...
@@ -7,6 +7,7 @@ import * as assert from 'assert';
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
sep
}
from
'
vs/base/common/path
'
;
import
{
isWindows
}
from
'
vs/base/common/platform
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
suite
(
'
Glob
'
,
()
=>
{
...
...
@@ -1019,4 +1020,9 @@ suite('Glob', () => {
assertNoGlobMatch
(
p
,
'
/DNXConsoleApp/foo/Program.cs
'
);
}
});
test
(
'
URI match
'
,
()
=>
{
let
p
=
'
scheme:/**/*.md
'
;
assertGlobMatch
(
p
,
URI
.
file
(
'
super/duper/long/some/file.md
'
).
with
({
scheme
:
'
scheme
'
}).
toString
());
});
});
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
浏览文件 @
059f2cf4
...
...
@@ -37,9 +37,10 @@ import { Lazy } from 'vs/base/common/lazy';
import
{
IResourceEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
NotebookDiffEditorInput
}
from
'
vs/workbench/contrib/notebook/browser/notebookDiffEditorInput
'
;
import
{
NotebookEditorInput
}
from
'
vs/workbench/contrib/notebook/common/notebookEditorInput
'
;
import
{
ContributedEditorPriority
,
IEditorAssociationsRegistry
,
IEditorOverrideService
,
IEditorType
,
IEditorTypesHandler
}
from
'
vs/workbench/services/editor/common/editorOverrideService
'
;
import
{
EditorExtensions
}
from
'
vs/workbench/common/editor
'
;
import
{
ContributedEditorPriority
,
DiffEditorInputFactoryFunction
,
EditorInputFactoryFunction
,
IEditorAssociationsRegistry
,
IEditorOverrideService
,
IEditorType
,
IEditorTypesHandler
}
from
'
vs/workbench/services/editor/common/editorOverrideService
'
;
import
{
EditorExtensions
,
IEditorInput
}
from
'
vs/workbench/common/editor
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
DiffEditorInput
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
export
class
NotebookProviderInfoStore
extends
Disposable
{
...
...
@@ -129,39 +130,52 @@ export class NotebookProviderInfoStore extends Disposable {
private
_registerContributionPoint
(
notebookProviderInfo
:
NotebookProviderInfo
):
void
{
for
(
const
selector
of
notebookProviderInfo
.
selectors
)
{
const
globPattern
=
(
selector
as
INotebookExclusiveDocumentFilter
).
include
||
selector
as
glob
.
IRelativePattern
|
string
;
const
notebookEditorInfo
=
{
id
:
notebookProviderInfo
.
id
,
label
:
notebookProviderInfo
.
displayName
,
detail
:
notebookProviderInfo
.
providerDisplayName
,
describes
:
(
currentEditor
:
IEditorInput
)
=>
currentEditor
instanceof
NotebookEditorInput
&&
currentEditor
.
viewType
===
notebookProviderInfo
.
id
,
priority
:
notebookProviderInfo
.
exclusive
?
ContributedEditorPriority
.
exclusive
:
notebookProviderInfo
.
priority
,
};
const
notebookEditorOptions
=
{
canHandleDiff
:
()
=>
!!
this
.
_configurationService
.
getValue
(
NotebookTextDiffEditorPreview
)
&&
!
this
.
_accessibilityService
.
isScreenReaderOptimized
(),
canSupportResource
:
(
resource
:
URI
)
=>
resource
.
scheme
===
Schemas
.
untitled
||
resource
.
scheme
===
Schemas
.
vscodeNotebookCell
||
this
.
_fileService
.
canHandleResource
(
resource
)
};
const
notebookEditorInputFactory
:
EditorInputFactoryFunction
=
(
resource
,
options
,
group
)
=>
{
const
data
=
CellUri
.
parse
(
resource
);
let
notebookUri
:
URI
=
resource
;
let
cellOptions
:
IResourceEditorInput
|
undefined
;
if
(
data
)
{
notebookUri
=
data
.
notebook
;
cellOptions
=
{
resource
:
resource
};
}
const
notebookOptions
=
new
NotebookEditorOptions
({
...
options
,
cellOptions
});
return
{
editor
:
NotebookEditorInput
.
create
(
this
.
_instantiationService
,
notebookUri
,
notebookProviderInfo
.
id
),
options
:
notebookOptions
};
};
const
notebookEditorDiffFactory
:
DiffEditorInputFactoryFunction
=
(
diffEditorInput
:
DiffEditorInput
,
options
,
group
)
=>
{
const
modifiedInput
=
diffEditorInput
.
modifiedInput
;
const
originalInput
=
diffEditorInput
.
originalInput
;
const
notebookUri
=
modifiedInput
.
resource
!
;
const
originalNotebookUri
=
originalInput
.
resource
!
;
return
{
editor
:
NotebookDiffEditorInput
.
create
(
this
.
_instantiationService
,
notebookUri
,
modifiedInput
.
getName
(),
originalNotebookUri
,
originalInput
.
getName
(),
diffEditorInput
.
getName
(),
notebookProviderInfo
.
id
)
};
};
// Register the notebook editor
this
.
_contributedEditorDisposables
.
add
(
this
.
_editorOverrideService
.
registerContributionPoint
(
globPattern
,
{
id
:
notebookProviderInfo
.
id
,
label
:
notebookProviderInfo
.
displayName
,
detail
:
notebookProviderInfo
.
providerDisplayName
,
describes
:
(
currentEditor
)
=>
currentEditor
instanceof
NotebookEditorInput
&&
currentEditor
.
viewType
===
notebookProviderInfo
.
id
,
priority
:
notebookProviderInfo
.
exclusive
?
ContributedEditorPriority
.
exclusive
:
notebookProviderInfo
.
priority
,
},
{
canHandleDiff
:
()
=>
!!
this
.
_configurationService
.
getValue
(
NotebookTextDiffEditorPreview
)
&&
!
this
.
_accessibilityService
.
isScreenReaderOptimized
(),
canSupportResource
:
resource
=>
resource
.
scheme
===
Schemas
.
untitled
||
resource
.
scheme
===
Schemas
.
vscodeNotebookCell
||
this
.
_fileService
.
canHandleResource
(
resource
)
},
(
resource
,
options
,
group
)
=>
{
const
data
=
CellUri
.
parse
(
resource
);
let
notebookUri
:
URI
=
resource
;
let
cellOptions
:
IResourceEditorInput
|
undefined
;
if
(
data
)
{
notebookUri
=
data
.
notebook
;
cellOptions
=
{
resource
:
resource
};
}
const
notebookOptions
=
new
NotebookEditorOptions
({
...
options
,
cellOptions
});
return
{
editor
:
NotebookEditorInput
.
create
(
this
.
_instantiationService
,
notebookUri
,
notebookProviderInfo
.
id
),
options
:
notebookOptions
};
},
(
diffEditorInput
,
group
)
=>
{
const
modifiedInput
=
diffEditorInput
.
modifiedInput
;
const
originalInput
=
diffEditorInput
.
originalInput
;
const
notebookUri
=
modifiedInput
.
resource
!
;
const
originalNotebookUri
=
originalInput
.
resource
!
;
return
{
editor
:
NotebookDiffEditorInput
.
create
(
this
.
_instantiationService
,
notebookUri
,
modifiedInput
.
getName
(),
originalNotebookUri
,
originalInput
.
getName
(),
diffEditorInput
.
getName
(),
notebookProviderInfo
.
id
)
};
}
notebookEditorInfo
,
notebookEditorOptions
,
notebookEditorInputFactory
,
notebookEditorDiffFactory
));
// Then register the schema handler as exclusive for that notebook
this
.
_contributedEditorDisposables
.
add
(
this
.
_editorOverrideService
.
registerContributionPoint
(
`
${
Schemas
.
vscodeNotebookCell
}
:/**/
${
globPattern
}
`
,
{
...
notebookEditorInfo
,
priority
:
ContributedEditorPriority
.
exclusive
},
notebookEditorOptions
,
notebookEditorInputFactory
,
notebookEditorDiffFactory
));
}
}
...
...
src/vs/workbench/services/editor/browser/editorOverrideService.ts
浏览文件 @
059f2cf4
...
...
@@ -226,8 +226,10 @@ export class EditorOverrideService extends Disposable implements IEditorOverride
const
associationsFromSetting
=
this
.
getAssociationsForResource
(
resource
);
// We only want built-in+ if no user defined setting is found, else we won't override
const
possibleContributionPoints
=
contributionPoints
.
filter
(
contribPoint
=>
priorityToRank
(
contribPoint
.
editorInfo
.
priority
)
>=
priorityToRank
(
ContributedEditorPriority
.
builtin
)
&&
contribPoint
.
editorInfo
.
id
!==
DEFAULT_EDITOR_ASSOCIATION
.
id
);
// If the user has a setting we use that, else choose the highest priority editor that is built-in+
const
selectedViewType
=
associationsFromSetting
[
0
]?.
viewType
||
possibleContributionPoints
[
0
]?.
editorInfo
.
id
;
// If the contribution is exclusive we use that, else use the user setting, else use the built-in+ contribution
const
selectedViewType
=
possibleContributionPoints
[
0
]?.
editorInfo
.
priority
===
ContributedEditorPriority
.
exclusive
?
possibleContributionPoints
[
0
]?.
editorInfo
.
id
:
associationsFromSetting
[
0
]?.
viewType
||
possibleContributionPoints
[
0
]?.
editorInfo
.
id
;
let
conflictingDefault
=
false
;
if
(
associationsFromSetting
.
length
===
0
&&
possibleContributionPoints
.
length
>
1
)
{
...
...
src/vs/workbench/services/editor/common/editorOverrideService.ts
浏览文件 @
059f2cf4
...
...
@@ -260,7 +260,7 @@ export function globMatchesResource(globPattern: string | glob.IRelativePattern,
return
false
;
}
const
matchOnPath
=
typeof
globPattern
===
'
string
'
&&
globPattern
.
indexOf
(
posix
.
sep
)
>=
0
;
const
target
=
matchOnPath
?
resource
.
path
:
basename
(
resource
);
const
target
=
matchOnPath
?
`
${
resource
.
scheme
}
:
${
resource
.
path
}
`
:
basename
(
resource
);
return
glob
.
match
(
globPattern
,
target
.
toLowerCase
());
}
//#endregion
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录