Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
9069070c
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,发现更多精彩内容 >>
提交
9069070c
编写于
6月 14, 2017
作者:
I
isidor
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into isidorn/explorerModel
上级
07b50d90
a7d864df
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
174 addition
and
80 deletion
+174
-80
build/tfs/darwin/smoketest.sh
build/tfs/darwin/smoketest.sh
+8
-1
src/vs/base/browser/dom.ts
src/vs/base/browser/dom.ts
+5
-0
src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts
src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts
+1
-0
src/vs/editor/browser/standalone/simpleServices.ts
src/vs/editor/browser/standalone/simpleServices.ts
+7
-3
src/vs/editor/browser/viewParts/minimap/minimap.ts
src/vs/editor/browser/viewParts/minimap/minimap.ts
+37
-5
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
+4
-4
src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts
...r/contrib/comment/test/common/blockCommentCommand.test.ts
+17
-17
src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts
...or/contrib/comment/test/common/lineCommentCommand.test.ts
+12
-12
src/vs/platform/workspace/common/workspace.ts
src/vs/platform/workspace/common/workspace.ts
+27
-7
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
+1
-1
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-1
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+2
-2
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
...vs/workbench/browser/parts/activitybar/activitybarPart.ts
+5
-0
src/vs/workbench/services/configuration/node/configuration.ts
...vs/workbench/services/configuration/node/configuration.ts
+38
-22
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+9
-5
未找到文件。
build/tfs/darwin/smoketest.sh
浏览文件 @
9069070c
...
...
@@ -24,4 +24,11 @@ step "Run unit tests" \
./scripts/test.sh
--build
--reporter
dot
step
"Run integration tests"
\
./scripts/test-integration.sh
\ No newline at end of file
./scripts/test-integration.sh
step
"Run smoke test"
\
pushd test
/smoke
npm
install
npm run compile
node src/main.js
--latest
"
$AGENT_BUILDDIRECTORY
/VSCode-darwin/Visual Studio Code - Insiders.app/Contents/MacOS/Electron"
popd
\ No newline at end of file
src/vs/base/browser/dom.ts
浏览文件 @
9069070c
...
...
@@ -1041,3 +1041,8 @@ export function domContentLoaded(): TPromise<any> {
}
});
}
export
function
hintGPULayer
(
target
:
HTMLElement
):
void
{
// This is to hint browsers that this dom node is suited to live in its own layer (e.g. sliders, etc.)
(
<
any
>
target
.
style
).
willChange
=
'
transform
'
;
}
src/vs/base/browser/ui/scrollbar/abstractScrollbar.ts
浏览文件 @
9069070c
...
...
@@ -170,6 +170,7 @@ export abstract class AbstractScrollbar extends Widget {
this
.
domNode
.
setTransform
(
'
translate3d(0px, 0px, 0px)
'
);
}
else
{
this
.
domNode
.
setTransform
(
''
);
DomUtils
.
hintGPULayer
(
this
.
domNode
.
domNode
);
}
this
.
_renderDomNode
(
this
.
_scrollbarState
.
getRectangleLargeSize
(),
this
.
_scrollbarState
.
getRectangleSmallSize
());
...
...
src/vs/editor/browser/standalone/simpleServices.ts
浏览文件 @
9069070c
...
...
@@ -17,7 +17,7 @@ import { KeybindingResolver } from 'vs/platform/keybinding/common/keybindingReso
import
{
IKeybindingEvent
,
KeybindingSource
,
IKeyboardEvent
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ContextKeyExpr
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfirmation
,
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IWorkspaceContextService
,
Workspace
,
IWorkspace
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspaceContextService
,
Workspace
,
IWorkspace
,
IWorkspace2
}
from
'
vs/platform/workspace/common/workspace
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
,
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
...
...
@@ -495,8 +495,8 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
public
_serviceBrand
:
any
;
private
readonly
_onDidChange
Folder
s
:
Emitter
<
URI
[]
>
=
new
Emitter
<
URI
[]
>
();
public
readonly
onDidChange
Folders
:
Event
<
URI
[]
>
=
this
.
_onDidChangeFolder
s
.
event
;
private
readonly
_onDidChange
WorkspaceRoot
s
:
Emitter
<
URI
[]
>
=
new
Emitter
<
URI
[]
>
();
public
readonly
onDidChange
WorkspaceRoots
:
Event
<
URI
[]
>
=
this
.
_onDidChangeWorkspaceRoot
s
.
event
;
private
readonly
folders
:
URI
[];
...
...
@@ -512,6 +512,10 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
return
this
.
workspace
;
}
public
getWorkspace2
():
IWorkspace2
{
return
this
.
workspace
?
{
id
:
`
${
this
.
workspace
.
uid
}
`
,
roots
:
[
this
.
workspace
.
resource
]
}
:
void
0
;
}
public
hasWorkspace
():
boolean
{
return
!!
this
.
workspace
;
}
...
...
src/vs/editor/browser/viewParts/minimap/minimap.ts
浏览文件 @
9069070c
...
...
@@ -413,6 +413,7 @@ export class Minimap extends ViewPart {
this
.
_slider
=
createFastDomNode
(
document
.
createElement
(
'
div
'
));
this
.
_slider
.
setPosition
(
'
absolute
'
);
this
.
_slider
.
setClassName
(
'
minimap-slider
'
);
dom
.
hintGPULayer
(
this
.
_slider
.
domNode
);
this
.
_domNode
.
appendChild
(
this
.
_slider
);
this
.
_tokensColorTracker
=
MinimapTokensColorTracker
.
getInstance
();
...
...
@@ -614,10 +615,41 @@ export class Minimap extends ViewPart {
this
.
_slider
.
setTop
(
layout
.
sliderTop
);
this
.
_slider
.
setHeight
(
layout
.
sliderHeight
);
this
.
_lastRenderData
=
this
.
renderLines
(
layout
);
}
private
renderLines
(
layout
:
MinimapLayout
):
RenderData
{
const
renderMinimap
=
this
.
_options
.
renderMinimap
;
const
startLineNumber
=
layout
.
startLineNumber
;
const
endLineNumber
=
layout
.
endLineNumber
;
const
minimapLineHeight
=
getMinimapLineHeight
(
renderMinimap
);
// Check if nothing changed w.r.t. lines from last frame
if
(
this
.
_lastRenderData
)
{
const
_lastData
=
this
.
_lastRenderData
.
_get
();
const
lastStartLineNumber
=
_lastData
.
rendLineNumberStart
;
const
lastLines
=
_lastData
.
lines
;
const
lastLinesLength
=
lastLines
.
length
;
let
linesNeedPainting
=
false
;
for
(
let
lineNumber
=
startLineNumber
;
lineNumber
<=
endLineNumber
;
lineNumber
++
)
{
const
lastLineIndex
=
lineNumber
-
lastStartLineNumber
;
const
source_dy
=
(
lastLineIndex
>=
0
&&
lastLineIndex
<
lastLinesLength
?
lastLines
[
lastLineIndex
].
dy
:
-
1
);
if
(
source_dy
===
-
1
)
{
linesNeedPainting
=
true
;
break
;
}
}
if
(
!
linesNeedPainting
)
{
// Nice!! Nothing changed from last frame
return
new
RenderData
(
layout
,
_lastData
.
imageData
,
_lastData
.
lines
);
}
}
// Oh well!! We need to repaint some lines...
const
imageData
=
this
.
_getBuffer
();
// Render untouched lines by using last rendered data.
...
...
@@ -656,16 +688,16 @@ export class Minimap extends ViewPart {
dy
+=
minimapLineHeight
;
}
// Finally, paint to the canvas
const
ctx
=
this
.
_canvas
.
domNode
.
getContext
(
'
2d
'
);
ctx
.
putImageData
(
imageData
,
0
,
0
);
// Save rendered data for reuse on next frame if possible
this
.
_lastRenderData
=
new
RenderData
(
return
new
RenderData
(
layout
,
imageData
,
renderedLines
);
// Finally, paint to the canvas
const
ctx
=
this
.
_canvas
.
domNode
.
getContext
(
'
2d
'
);
ctx
.
putImageData
(
imageData
,
0
,
0
);
}
private
static
_renderUntouchedLines
(
...
...
src/vs/editor/contrib/comment/common/blockCommentCommand.ts
浏览文件 @
9069070c
...
...
@@ -97,16 +97,16 @@ export class BlockCommentCommand implements editorCommon.ICommand {
if
(
!
Range
.
isEmpty
(
r
))
{
// Insert block comment start
res
.
push
(
EditOperation
.
insert
(
new
Position
(
r
.
startLineNumber
,
r
.
startColumn
),
startToken
));
res
.
push
(
EditOperation
.
insert
(
new
Position
(
r
.
startLineNumber
,
r
.
startColumn
),
startToken
+
'
'
));
// Insert block comment end
res
.
push
(
EditOperation
.
insert
(
new
Position
(
r
.
endLineNumber
,
r
.
endColumn
),
endToken
));
res
.
push
(
EditOperation
.
insert
(
new
Position
(
r
.
endLineNumber
,
r
.
endColumn
),
'
'
+
endToken
));
}
else
{
// Insert both continuously
res
.
push
(
EditOperation
.
replace
(
new
Range
(
r
.
startLineNumber
,
r
.
startColumn
,
r
.
endLineNumber
,
r
.
endColumn
),
startToken
+
endToken
));
),
startToken
+
'
'
+
endToken
));
}
return
res
;
...
...
@@ -145,7 +145,7 @@ export class BlockCommentCommand implements editorCommon.ICommand {
);
}
else
{
var
srcRange
=
inverseEditOperations
[
0
].
range
;
var
deltaColumn
=
this
.
_usedEndToken
?
-
this
.
_usedEndToken
.
length
:
0
;
var
deltaColumn
=
this
.
_usedEndToken
?
-
this
.
_usedEndToken
.
length
-
1
:
0
;
// minus 1 space before endToken
return
new
Selection
(
srcRange
.
endLineNumber
,
srcRange
.
endColumn
+
deltaColumn
,
...
...
src/vs/editor/contrib/comment/test/common/blockCommentCommand.test.ts
浏览文件 @
9069070c
...
...
@@ -28,13 +28,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
1
,
3
,
1
,
3
),
[
'
fi<00>rst
'
,
'
fi<0
0>rst
'
,
'
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
5
,
1
,
5
)
new
Selection
(
1
,
6
,
1
,
6
)
);
});
...
...
@@ -49,13 +49,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
2
,
1
,
1
,
1
),
[
'
<0first
'
,
'
0>
\t
second line
'
,
'
<0
first
'
,
'
0>
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
3
,
2
,
1
)
new
Selection
(
1
,
4
,
2
,
1
)
);
});
...
...
@@ -70,13 +70,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
1
,
6
,
1
,
1
),
[
'
<0
first
0>
'
,
'
<0
first
0>
'
,
'
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
3
,
1
,
8
)
new
Selection
(
1
,
4
,
1
,
9
)
);
testBlockCommentCommand
(
...
...
@@ -110,13 +110,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
1
,
6
,
1
,
3
),
[
'
fi<0
rst
0>
'
,
'
fi<0
rst
0>
'
,
'
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
5
,
1
,
8
)
new
Selection
(
1
,
6
,
1
,
9
)
);
});
...
...
@@ -131,13 +131,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
1
,
6
,
1
,
3
),
[
'
fi<0
rst
0>
'
,
'
fi<0
rst
0>
'
,
'
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
5
,
1
,
8
)
new
Selection
(
1
,
6
,
1
,
9
)
);
testBlockCommentCommand
(
...
...
@@ -171,13 +171,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
2
,
4
,
1
,
1
),
[
'
<0first
'
,
'
\t
se0>cond line
'
,
'
<0
first
'
,
'
\t
se
0>cond line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
3
,
2
,
4
)
new
Selection
(
1
,
4
,
2
,
4
)
);
});
...
...
@@ -192,13 +192,13 @@ suite('Editor Contrib - Block Comment Command', () => {
],
new
Selection
(
2
,
4
,
1
,
1
),
[
'
<0first
'
,
'
\t
se0>cond line
'
,
'
<0
first
'
,
'
\t
se
0>cond line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
3
,
2
,
4
)
new
Selection
(
1
,
4
,
2
,
4
)
);
testBlockCommentCommand
(
...
...
src/vs/editor/contrib/comment/test/common/lineCommentCommand.test.ts
浏览文件 @
9069070c
...
...
@@ -544,13 +544,13 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
],
new
Selection
(
1
,
1
,
1
,
1
),
[
'
(
first
)
'
,
'
(
first
)
'
,
'
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
2
,
1
,
2
)
new
Selection
(
1
,
3
,
1
,
3
)
);
});
...
...
@@ -586,13 +586,13 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
],
new
Selection
(
1
,
1
,
1
,
1
),
[
'
(
first
)
'
,
'
(
first
)
'
,
'
\t
second line
'
,
'
third line
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
2
,
1
,
2
)
new
Selection
(
1
,
3
,
1
,
3
)
);
});
...
...
@@ -607,13 +607,13 @@ suite('Editor Contrib - Line Comment As Block Comment', () => {
],
new
Selection
(
3
,
2
,
1
,
3
),
[
'
(first
'
,
'
(
first
'
,
'
\t
second line
'
,
'
third line)
'
,
'
third line
)
'
,
'
fourth line
'
,
'
fifth
'
],
new
Selection
(
1
,
4
,
3
,
2
)
new
Selection
(
1
,
5
,
3
,
2
)
);
testLineCommentCommand
(
...
...
@@ -655,7 +655,7 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
],
new
Selection
(
1
,
1
,
1
,
1
),
[
'
\t\t
<!@#
first
\t
#@!>
'
,
'
\t\t
<!@#
first
\t
#@!>
'
,
'
\t\t
second line
'
,
'
\t
third line
'
,
'
fourth line
'
,
...
...
@@ -809,8 +809,8 @@ suite('Editor Contrib - Line Comment As Block Comment 2', () => {
],
new
Selection
(
1
,
1
,
3
,
1
),
[
'
<!@#asd qwe
'
,
'
asd qwe#@!>
'
,
'
<!@#
asd qwe
'
,
'
asd qwe
#@!>
'
,
''
],
new
Selection
(
1
,
1
,
3
,
1
)
...
...
@@ -927,13 +927,13 @@ suite('Editor Contrib - Line Comment in mixed modes', () => {
[
'
import React from
\'
react
\'
;
'
,
'
const Loader = () => (
'
,
'
{/*
<div>
*/}
'
,
'
{/*
<div>
*/}
'
,
'
Loading...
'
,
'
</div>
'
,
'
);
'
,
'
export default Loader;
'
],
new
Selection
(
3
,
7
,
3
,
7
),
new
Selection
(
3
,
8
,
3
,
8
),
);
});
...
...
src/vs/platform/workspace/common/workspace.ts
浏览文件 @
9069070c
...
...
@@ -27,6 +27,17 @@ export interface IWorkspaceContextService {
*/
getWorkspace
():
IWorkspace
;
/**
* Provides access to the workspace object the platform is running with. This may be null if the workbench was opened
* without workspace (empty);
*/
getWorkspace2
():
IWorkspace2
;
/**
* An event which fires on workspace roots change.
*/
onDidChangeWorkspaceRoots
:
Event
<
URI
[]
>
;
/**
* Returns iff the provided resource is inside the workspace or not.
*/
...
...
@@ -44,11 +55,6 @@ export interface IWorkspaceContextService {
*/
toResource
:
(
workspaceRelativePath
:
string
)
=>
URI
;
/**
* TODO@Ben multiroot
*/
getFolders
():
URI
[];
onDidChangeFolders
:
Event
<
URI
[]
>
;
}
export
interface
IWorkspace
{
...
...
@@ -72,6 +78,20 @@ export interface IWorkspace {
name
?:
string
;
}
export
interface
IWorkspace2
{
/**
* the unique identifier of the workspace.
*/
readonly
id
:
string
;
/**
* Mutliple roots in this workspace. First entry is master and never changes.
*/
readonly
roots
:
URI
[];
}
export
class
Workspace
implements
IWorkspace
{
constructor
(
private
_resource
:
URI
,
private
_uid
?:
number
,
private
_name
?:
string
)
{
...
...
@@ -105,9 +125,9 @@ export class Workspace implements IWorkspace {
return
null
;
}
public
toResource
(
workspaceRelativePath
:
string
):
URI
{
public
toResource
(
workspaceRelativePath
:
string
,
root
?:
URI
):
URI
{
if
(
typeof
workspaceRelativePath
===
'
string
'
)
{
return
URI
.
file
(
paths
.
join
(
this
.
_resource
.
fsPath
,
workspaceRelativePath
));
return
URI
.
file
(
paths
.
join
(
root
?
root
.
fsPath
:
this
.
_resource
.
fsPath
,
workspaceRelativePath
));
}
return
null
;
...
...
src/vs/workbench/api/electron-browser/mainThreadWorkspace.ts
浏览文件 @
9069070c
...
...
@@ -37,7 +37,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
)
{
super
();
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostWorkspace
);
this
.
_contextService
.
onDidChange
Folder
s
(
this
.
_onDidChangeWorkspace
,
this
,
this
.
_toDispose
);
this
.
_contextService
.
onDidChange
WorkspaceRoot
s
(
this
.
_onDidChangeWorkspace
,
this
,
this
.
_toDispose
);
}
// --- workspace ---
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
9069070c
...
...
@@ -408,7 +408,7 @@ export function createApiFactory(
onWillSaveTextDocument
:
(
listener
,
thisArgs
?,
disposables
?)
=>
{
return
extHostDocumentSaveParticipant
.
onWillSaveTextDocumentEvent
(
listener
,
thisArgs
,
disposables
);
},
onDidChangeConfiguration
:
(
listener
:
()
=>
any
,
thisArgs
?:
any
,
disposables
?:
extHostTypes
.
Disposable
[])
=>
{
onDidChangeConfiguration
:
(
listener
:
(
_
:
any
)
=>
any
,
thisArgs
?:
any
,
disposables
?:
extHostTypes
.
Disposable
[])
=>
{
return
extHostConfiguration
.
onDidChangeConfiguration
(
listener
,
thisArgs
,
disposables
);
},
getConfiguration
:
(
section
?:
string
):
vscode
.
WorkspaceConfiguration
=>
{
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
9069070c
...
...
@@ -316,14 +316,14 @@ export class ExtHostSCM {
return
sourceControl
;
}
$provideOriginalResource
(
sourceControlHandle
:
number
,
uri
:
URI
):
TPromise
<
vscode
.
Uri
>
{
$provideOriginalResource
(
sourceControlHandle
:
number
,
uri
:
URI
):
TPromise
<
URI
>
{
const
sourceControl
=
this
.
_sourceControls
.
get
(
sourceControlHandle
);
if
(
!
sourceControl
||
!
sourceControl
.
quickDiffProvider
)
{
return
TPromise
.
as
(
null
);
}
return
asWinJsPromise
(
token
=>
sourceControl
.
quickDiffProvider
.
provideOriginalResource
(
uri
,
token
));
return
asWinJsPromise
(
token
=>
URI
.
parse
(
sourceControl
.
quickDiffProvider
.
provideOriginalResource
(
uri
,
token
).
toString
()
));
}
$onActiveSourceControlChange
(
handle
:
number
):
TPromise
<
void
>
{
...
...
src/vs/workbench/browser/parts/activitybar/activitybarPart.ts
浏览文件 @
9069070c
...
...
@@ -293,6 +293,11 @@ export class ActivitybarPart extends Part implements IActivityBarService {
}
private
updateViewletSwitcher
()
{
if
(
!
this
.
viewletSwitcherBar
)
{
// We have not been rendered yet so there is nothing to update.
return
;
}
let
viewletsToShow
=
this
.
getPinnedViewlets
();
// Always show the active viewlet even if it is marked to be hidden
...
...
src/vs/workbench/services/configuration/node/configuration.ts
浏览文件 @
9069070c
...
...
@@ -17,7 +17,7 @@ import { Schemas } from "vs/base/common/network";
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
readFile
}
from
'
vs/base/node/pfs
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
import
{
IWorkspaceContextService
,
Workspace
,
IWorkspace
}
from
"
vs/platform/workspace/common/workspace
"
;
import
{
IWorkspaceContextService
,
IWorkspace2
,
Workspace
as
SingleRoot
Workspace
,
IWorkspace
}
from
"
vs/platform/workspace/common/workspace
"
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
FileChangeType
,
FileChangesEvent
,
isEqual
}
from
'
vs/platform/files/common/files
'
;
import
{
ConfigModel
}
from
'
vs/platform/configuration/common/model
'
;
...
...
@@ -44,14 +44,29 @@ interface IWorkspaceConfiguration<T> {
type
IWorkspaceFoldersConfiguration
=
{
[
rootFolder
:
string
]:
{
folders
:
string
[];
}
};
class
Workspace
implements
IWorkspace2
{
constructor
(
readonly
id
:
string
,
private
_roots
:
URI
[])
{
}
get
roots
():
URI
[]
{
return
this
.
_roots
;
}
setRoots
(
roots
:
URI
[]):
void
{
this
.
_roots
=
roots
;
}
}
export
class
WorkspaceConfigurationService
extends
Disposable
implements
IWorkspaceContextService
,
IWorkspaceConfigurationService
{
private
static
RELOAD_CONFIGURATION_DELAY
=
50
;
public
_serviceBrand
:
any
;
private
readonly
_onDidChange
Folder
s
:
Emitter
<
URI
[]
>
=
this
.
_register
(
new
Emitter
<
URI
[]
>
());
public
readonly
onDidChange
Folders
:
Event
<
URI
[]
>
=
this
.
_onDidChangeFolder
s
.
event
;
private
readonly
_onDidChange
WorkspaceRoot
s
:
Emitter
<
URI
[]
>
=
this
.
_register
(
new
Emitter
<
URI
[]
>
());
public
readonly
onDidChange
WorkspaceRoots
:
Event
<
URI
[]
>
=
this
.
_onDidChangeWorkspaceRoot
s
.
event
;
private
readonly
_onDidUpdateConfiguration
:
Emitter
<
IConfigurationServiceEvent
>
=
this
.
_register
(
new
Emitter
<
IConfigurationServiceEvent
>
());
public
readonly
onDidUpdateConfiguration
:
Event
<
IConfigurationServiceEvent
>
=
this
.
_onDidUpdateConfiguration
.
event
;
...
...
@@ -65,12 +80,12 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
private
workspaceFilePathToConfiguration
:
{
[
relativeWorkspacePath
:
string
]:
TPromise
<
IConfigModel
<
any
>>
};
private
reloadConfigurationScheduler
:
RunOnceScheduler
;
private
folders
:
URI
[]
;
private
readonly
workspace
:
Workspace
;
constructor
(
private
environmentService
:
IEnvironmentService
,
private
workspace
?:
Workspace
,
private
workspaceSettingsRootFolder
:
string
=
WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME
)
{
constructor
(
private
environmentService
:
IEnvironmentService
,
private
singleRootWorkspace
?:
SingleRoot
Workspace
,
private
workspaceSettingsRootFolder
:
string
=
WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME
)
{
super
();
this
.
folders
=
workspace
?
[
workspace
.
resource
]
:
[]
;
this
.
workspace
=
singleRootWorkspace
?
new
Workspace
(
`
${
singleRootWorkspace
.
uid
}
`
,
[
singleRootWorkspace
.
resource
])
:
null
;
this
.
workspaceFilePathToConfiguration
=
Object
.
create
(
null
);
this
.
cachedConfig
=
new
ConfigModel
<
any
>
(
null
);
...
...
@@ -95,10 +110,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
}
// Resovled configured folders for workspace
let
configuredFolders
:
URI
[]
=
[
this
.
workspace
.
resource
];
let
[
master
]
=
this
.
workspace
.
roots
;
let
configuredFolders
:
URI
[]
=
[
master
];
const
config
=
this
.
getConfiguration
<
IWorkspaceFoldersConfiguration
>
(
'
workspace
'
);
if
(
config
)
{
const
workspaceConfig
=
config
[
this
.
workspace
.
resource
.
toString
()];
const
workspaceConfig
=
config
[
master
.
toString
()];
if
(
workspaceConfig
)
{
const
additionalFolders
=
workspaceConfig
.
folders
.
map
(
f
=>
URI
.
parse
(
f
))
...
...
@@ -112,20 +128,20 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
configuredFolders
=
distinct
(
configuredFolders
,
r
=>
r
.
toString
());
// Find changes
const
changed
=
!
equals
(
this
.
folder
s
,
configuredFolders
,
(
r1
,
r2
)
=>
r1
.
toString
()
===
r2
.
toString
());
const
changed
=
!
equals
(
this
.
workspace
.
root
s
,
configuredFolders
,
(
r1
,
r2
)
=>
r1
.
toString
()
===
r2
.
toString
());
this
.
folders
=
configuredFolders
;
this
.
workspace
.
setRoots
(
configuredFolders
)
;
if
(
notify
&&
changed
)
{
this
.
_onDidChange
Folder
s
.
fire
(
configuredFolders
);
this
.
_onDidChange
WorkspaceRoot
s
.
fire
(
configuredFolders
);
}
}
public
get
Folders
():
URI
[]
{
return
this
.
folders
;
public
get
Workspace
():
IWorkspace
{
return
this
.
singleRootWorkspace
;
}
public
getWorkspace
():
IWorkspace
{
public
getWorkspace
2
():
IWorkspace2
{
return
this
.
workspace
;
}
...
...
@@ -134,15 +150,15 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
}
public
isInsideWorkspace
(
resource
:
URI
):
boolean
{
return
this
.
workspace
?
this
.
w
orkspace
.
isInsideWorkspace
(
resource
)
:
false
;
return
this
.
workspace
?
this
.
singleRootW
orkspace
.
isInsideWorkspace
(
resource
)
:
false
;
}
public
toWorkspaceRelativePath
(
resource
:
URI
,
toOSPath
?:
boolean
):
string
{
return
this
.
workspace
?
this
.
w
orkspace
.
toWorkspaceRelativePath
(
resource
,
toOSPath
)
:
null
;
return
this
.
workspace
?
this
.
singleRootW
orkspace
.
toWorkspaceRelativePath
(
resource
,
toOSPath
)
:
null
;
}
public
toResource
(
workspaceRelativePath
:
string
):
URI
{
return
this
.
workspace
?
this
.
w
orkspace
.
toResource
(
workspaceRelativePath
)
:
null
;
return
this
.
workspace
?
this
.
singleRootW
orkspace
.
toResource
(
workspaceRelativePath
)
:
null
;
}
private
onBaseConfigurationChanged
(
event
:
IConfigurationServiceEvent
):
void
{
...
...
@@ -276,7 +292,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
// once: when invoked for the first time we fetch json files that contribute settings
if
(
!
this
.
bulkFetchFromWorkspacePromise
)
{
this
.
bulkFetchFromWorkspacePromise
=
resolveStat
(
this
.
workspace
.
toResource
(
this
.
workspaceSettingsRootFolder
)).
then
(
stat
=>
{
this
.
bulkFetchFromWorkspacePromise
=
resolveStat
(
this
.
toResource
(
this
.
workspaceSettingsRootFolder
)).
then
(
stat
=>
{
if
(
!
stat
.
isDirectory
)
{
return
TPromise
.
as
([]);
}
...
...
@@ -287,11 +303,11 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
return
false
;
// only JSON files
}
return
this
.
isWorkspaceConfigurationFile
(
this
.
workspace
.
toWorkspaceRelativePath
(
stat
.
resource
));
// only workspace config files
return
this
.
isWorkspaceConfigurationFile
(
this
.
toWorkspaceRelativePath
(
stat
.
resource
));
// only workspace config files
}).
map
(
stat
=>
stat
.
resource
));
},
err
=>
[]
/* never fail this call */
)
.
then
((
contents
:
IContent
[])
=>
{
contents
.
forEach
(
content
=>
this
.
workspaceFilePathToConfiguration
[
this
.
workspace
.
toWorkspaceRelativePath
(
content
.
resource
)]
=
TPromise
.
as
(
this
.
createConfigModel
(
content
)));
contents
.
forEach
(
content
=>
this
.
workspaceFilePathToConfiguration
[
this
.
toWorkspaceRelativePath
(
content
.
resource
)]
=
TPromise
.
as
(
this
.
createConfigModel
(
content
)));
},
errors
.
onUnexpectedError
);
}
...
...
@@ -317,7 +333,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
continue
;
// only JSON files or the actual settings folder
}
const
workspacePath
=
this
.
workspace
.
toWorkspaceRelativePath
(
resource
);
const
workspacePath
=
this
.
toWorkspaceRelativePath
(
resource
);
if
(
!
workspacePath
)
{
continue
;
// event is not inside workspace
}
...
...
@@ -353,7 +369,7 @@ export class WorkspaceConfigurationService extends Disposable implements IWorksp
}
private
createConfigModel
<
T
>
(
content
:
IContent
):
IConfigModel
<
T
>
{
const
path
=
this
.
workspace
.
toWorkspaceRelativePath
(
content
.
resource
);
const
path
=
this
.
toWorkspaceRelativePath
(
content
.
resource
);
if
(
path
===
WORKSPACE_CONFIG_DEFAULT_PATH
)
{
return
new
WorkspaceSettingsConfigModel
<
T
>
(
content
.
value
,
content
.
resource
.
toString
());
}
else
{
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
9069070c
...
...
@@ -27,7 +27,7 @@ import { ITextModelService } from 'vs/editor/common/services/resolverService';
import
{
IEditorInput
,
IEditorOptions
,
Position
,
Direction
,
IEditor
,
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IUntitledEditorService
,
UntitledEditorService
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
import
{
IMessageService
,
IConfirmation
}
from
'
vs/platform/message/common/message
'
;
import
{
IWorkspace
,
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IWorkspace
,
IWorkspaceContextService
,
IWorkspace2
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
ILifecycleService
,
ShutdownEvent
,
ShutdownReason
,
StartupKind
,
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
EditorStacksModel
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
...
...
@@ -66,16 +66,16 @@ export class TestContextService implements IWorkspaceContextService {
private
workspace
:
any
;
private
options
:
any
;
private
_onDidChange
Folder
s
:
Emitter
<
URI
[]
>
;
private
_onDidChange
WorkspaceRoot
s
:
Emitter
<
URI
[]
>
;
constructor
(
workspace
:
any
=
TestWorkspace
,
options
:
any
=
null
)
{
this
.
workspace
=
workspace
;
this
.
options
=
options
||
Object
.
create
(
null
);
this
.
_onDidChange
Folder
s
=
new
Emitter
<
URI
[]
>
();
this
.
_onDidChange
WorkspaceRoot
s
=
new
Emitter
<
URI
[]
>
();
}
public
get
onDidChange
Folder
s
():
Event
<
URI
[]
>
{
return
this
.
_onDidChange
Folder
s
.
event
;
public
get
onDidChange
WorkspaceRoot
s
():
Event
<
URI
[]
>
{
return
this
.
_onDidChange
WorkspaceRoot
s
.
event
;
}
public
getFolders
():
URI
[]
{
...
...
@@ -90,6 +90,10 @@ export class TestContextService implements IWorkspaceContextService {
return
this
.
workspace
;
}
public
getWorkspace2
():
IWorkspace2
{
return
this
.
workspace
?
{
id
:
`
${
this
.
workspace
.
uid
}
`
,
roots
:
[
this
.
workspace
.
resource
]
}
:
void
0
;
}
public
setWorkspace
(
workspace
:
any
):
void
{
this
.
workspace
=
workspace
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录