Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
263e346c
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
263e346c
编写于
10月 20, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' into ben/1.3.8
上级
256f59bf
6047eb47
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
165 addition
and
46 deletion
+165
-46
extensions/git/package.json
extensions/git/package.json
+1
-0
src/typings/thenable.d.ts
src/typings/thenable.d.ts
+3
-3
src/vs/editor/contrib/folding/browser/folding.ts
src/vs/editor/contrib/folding/browser/folding.ts
+15
-37
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+3
-3
src/vs/workbench/parts/html/browser/html.contribution.ts
src/vs/workbench/parts/html/browser/html.contribution.ts
+40
-1
src/vs/workbench/parts/html/browser/htmlEditorZone.ts
src/vs/workbench/parts/html/browser/htmlEditorZone.ts
+95
-0
src/vs/workbench/parts/html/browser/webview.ts
src/vs/workbench/parts/html/browser/webview.ts
+8
-2
未找到文件。
extensions/git/package.json
浏览文件 @
263e346c
{
"name"
:
"git"
,
"publisher"
:
"vscode"
,
"displayName"
:
"git"
,
"description"
:
"Git"
,
"version"
:
"0.0.1"
,
...
...
src/typings/thenable.d.ts
浏览文件 @
263e346c
...
...
@@ -9,13 +9,13 @@
* enables reusing existing code without migrating to a specific promise implementation. Still,
* we recommend the use of native promises which are available in VS Code.
*/
interface
Thenable
<
R
>
{
interface
Thenable
<
T
>
{
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Thenable
<
TResult
>
;
}
\ No newline at end of file
src/vs/editor/contrib/folding/browser/folding.ts
浏览文件 @
263e346c
...
...
@@ -189,53 +189,31 @@ export class FoldingController implements editorCommon.IEditorContribution {
return
;
}
this
.
contentChangedScheduler
=
new
RunOnceScheduler
(()
=>
{
let
myToken
=
(
++
this
.
computeToken
);
this
.
computeCollapsibleRegions
().
then
(
regions
=>
{
if
(
myToken
!==
this
.
computeToken
)
{
return
;
// A new request was made in the meantime or the model was changed
}
this
.
applyRegions
(
regions
);
});
},
200
);
this
.
cursorChangedScheduler
=
new
RunOnceScheduler
(()
=>
{
this
.
revealCursor
();
},
200
);
this
.
computeAndApplyCollapsibleRegions
();
this
.
contentChangedScheduler
=
new
RunOnceScheduler
(()
=>
this
.
computeAndApplyCollapsibleRegions
(),
200
);
this
.
cursorChangedScheduler
=
new
RunOnceScheduler
(()
=>
this
.
revealCursor
(),
200
);
this
.
localToDispose
.
push
(
this
.
contentChangedScheduler
);
this
.
localToDispose
.
push
(
this
.
cursorChangedScheduler
);
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeModelContent
(()
=>
{
this
.
contentChangedScheduler
.
schedule
();
}));
this
.
localToDispose
.
push
({
dispose
:
()
=>
{
++
this
.
computeToken
;
this
.
editor
.
changeDecorations
(
changeAccessor
=>
{
this
.
decorations
.
forEach
(
dec
=>
dec
.
dispose
(
changeAccessor
));
});
this
.
decorations
=
[];
this
.
editor
.
setHiddenAreas
([]);
}
});
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeModelContent
(
e
=>
this
.
contentChangedScheduler
.
schedule
()));
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeCursorPosition
(
e
=>
this
.
cursorChangedScheduler
.
schedule
()));
this
.
localToDispose
.
push
(
this
.
editor
.
onMouseDown
(
e
=>
this
.
onEditorMouseDown
(
e
)));
this
.
localToDispose
.
push
(
this
.
editor
.
onMouseUp
(
e
=>
this
.
onEditorMouseUp
(
e
)));
this
.
localToDispose
.
push
(
this
.
editor
.
onDidChangeCursorPosition
(
e
=>
{
this
.
cursorChangedScheduler
.
schedule
();
}));
this
.
contentChangedScheduler
.
schedule
(
);
this
.
localToDispose
.
push
({
dispose
:
()
=>
this
.
disposeDecorations
()
}
);
}
private
compute
CollapsibleRegions
():
TPromise
<
IFoldingRange
[]
>
{
private
compute
AndApplyCollapsibleRegions
():
void
{
let
model
=
this
.
editor
.
getModel
();
if
(
!
model
)
{
return
TPromise
.
as
([]);
}
this
.
applyRegions
(
model
?
computeRanges
(
model
)
:
[]);
}
let
ranges
=
computeRanges
(
model
);
return
TPromise
.
as
(
ranges
);
private
disposeDecorations
()
{
this
.
editor
.
changeDecorations
(
changeAccessor
=>
{
this
.
decorations
.
forEach
(
dec
=>
dec
.
dispose
(
changeAccessor
));
});
this
.
decorations
=
[];
this
.
editor
.
setHiddenAreas
([]);
}
private
revealCursor
()
{
...
...
src/vs/vscode.d.ts
浏览文件 @
263e346c
...
...
@@ -4203,13 +4203,13 @@ declare module 'vscode' {
* enables reusing existing code without migrating to a specific promise implementation. Still,
* we recommend the use of native promises which are available in VS Code.
*/
interface
Thenable
<
R
>
{
interface
Thenable
<
T
>
{
/**
* Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved.
* @param onrejected The callback to execute when the Promise is rejected.
* @returns A Promise for the completion of which ever callback is executed.
*/
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
R
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
TResult
|
Thenable
<
TResult
>
):
Thenable
<
TResult
>
;
then
<
TResult
>
(
onfulfilled
?:
(
value
:
T
)
=>
TResult
|
Thenable
<
TResult
>
,
onrejected
?:
(
reason
:
any
)
=>
void
):
Thenable
<
TResult
>
;
}
src/vs/workbench/parts/html/browser/html.contribution.ts
浏览文件 @
263e346c
...
...
@@ -4,11 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Position
as
EditorPosition
}
from
'
vs/platform/editor/common/editor
'
;
import
{
HtmlInput
}
from
'
../common/htmlInput
'
;
import
{
HtmlPreviewPart
}
from
'
vs/workbench/parts/html/browser/htmlPreviewPart
'
;
...
...
@@ -17,6 +17,8 @@ import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
import
{
IEditorRegistry
,
Extensions
as
EditorExtensions
}
from
'
vs/workbench/common/editor
'
;
import
{
SyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
isCommonCodeEditor
,
ICommonCodeEditor
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
HtmlZoneController
}
from
'
./htmlEditorZone
'
;
// --- Register Editor
(
<
IEditorRegistry
>
Registry
.
as
(
EditorExtensions
.
Editors
)).
registerEditor
(
new
EditorDescriptor
(
HtmlPreviewPart
.
ID
,
...
...
@@ -27,6 +29,43 @@ import { IEditorGroupService } from 'vs/workbench/services/group/common/groupSer
// --- Register Commands
interface
HtmlZoneParams
{
editorPosition
:
EditorPosition
;
lineNumber
:
number
;
resource
:
URI
;
}
let
warn
=
true
;
CommandsRegistry
.
registerCommand
(
'
_workbench.htmlZone
'
,
function
(
accessor
:
ServicesAccessor
,
params
:
HtmlZoneParams
)
{
if
(
warn
)
{
console
.
warn
(
`'_workbench.htmlZone' is an EXPERIMENTAL feature and therefore subject to CHANGE and REMOVAL without notice.`
);
warn
=
false
;
}
let
codeEditor
:
ICommonCodeEditor
;
for
(
const
editor
of
accessor
.
get
(
IWorkbenchEditorService
).
getVisibleEditors
())
{
if
(
editor
.
position
===
params
.
editorPosition
)
{
const
control
=
editor
.
getControl
();
if
(
isCommonCodeEditor
(
control
))
{
codeEditor
=
control
;
}
}
}
if
(
!
codeEditor
)
{
console
.
warn
(
'
NO matching editor found
'
);
return
;
}
return
accessor
.
get
(
IWorkbenchEditorService
).
resolveEditorModel
({
resource
:
params
.
resource
}).
then
(
model
=>
{
const
contents
=
(
<
IModel
>
model
.
textEditorModel
).
getValue
();
HtmlZoneController
.
getInstance
(
codeEditor
).
addZone
(
params
.
lineNumber
,
contents
);
});
});
CommandsRegistry
.
registerCommand
(
'
_workbench.previewHtml
'
,
function
(
accessor
:
ServicesAccessor
,
resource
:
URI
|
string
,
position
?:
EditorPosition
,
label
?:
string
)
{
const
uri
=
resource
instanceof
URI
?
resource
:
URI
.
parse
(
resource
);
...
...
src/vs/workbench/parts/html/browser/htmlEditorZone.ts
0 → 100644
浏览文件 @
263e346c
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IEditorContribution
,
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
,
IViewZone
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
editorContribution
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
Webview
from
'
./webview
'
;
class
HtmlZone
implements
IViewZone
{
zoneId
:
number
;
private
_domNode
:
HTMLElement
;
private
_webview
:
Webview
;
private
_disposables
:
IDisposable
[]
=
[];
constructor
(
public
lineNumber
:
number
,
public
htmlContent
:
string
)
{
}
dispose
():
void
{
dispose
(
this
.
_disposables
);
}
get
domNode
():
HTMLElement
{
if
(
!
this
.
_domNode
)
{
this
.
_domNode
=
document
.
createElement
(
'
div
'
);
const
observer
=
new
MutationObserver
(
_
=>
this
.
_onVisibilityChanged
());
observer
.
observe
(
this
.
_domNode
,
{
attributes
:
true
,
attributeFilter
:
[
'
monaco-visible-view-zone
'
]
});
this
.
_disposables
.
push
({
dispose
:
()
=>
observer
.
disconnect
()
});
}
return
this
.
_domNode
;
}
private
_onVisibilityChanged
():
void
{
if
(
this
.
_domNode
.
hasAttribute
(
'
monaco-visible-view-zone
'
)
&&
!
this
.
_webview
)
{
this
.
_webview
=
new
Webview
(
this
.
domNode
,
document
.
querySelector
(
'
.monaco-editor-background
'
));
this
.
_disposables
.
push
(
this
.
_webview
);
this
.
_webview
.
contents
=
[
this
.
htmlContent
];
}
}
get
afterLineNumber
():
number
{
return
this
.
lineNumber
;
}
get
heightInLines
():
number
{
return
6
;
}
get
suppressMouseDown
():
boolean
{
return
false
;
}
}
@
editorContribution
export
class
HtmlZoneController
implements
IEditorContribution
{
static
getInstance
(
editor
:
ICommonCodeEditor
):
HtmlZoneController
{
return
<
HtmlZoneController
>
editor
.
getContribution
(
'
htmlZoneContribution
'
);
}
private
_editor
:
ICodeEditor
;
private
_zones
:
HtmlZone
[]
=
[];
constructor
(
editor
:
ICodeEditor
)
{
this
.
_editor
=
editor
;
this
.
_editor
.
onDidChangeModel
(()
=>
this
.
_zones
=
dispose
(
this
.
_zones
));
}
getId
():
string
{
return
'
htmlZoneContribution
'
;
}
dispose
():
void
{
dispose
(
this
.
_zones
);
}
addZone
(
lineNumber
:
number
,
htmlContents
:
string
):
void
{
const
zone
=
new
HtmlZone
(
lineNumber
,
htmlContents
);
this
.
_zones
.
push
(
zone
);
this
.
_editor
.
changeViewZones
(
accessor
=>
{
zone
.
zoneId
=
accessor
.
addZone
(
zone
);
console
.
log
(
'
ADDED new zone #
'
,
zone
.
zoneId
);
});
}
}
src/vs/workbench/parts/html/browser/webview.ts
浏览文件 @
263e346c
...
...
@@ -49,7 +49,7 @@ export default class Webview {
private
_onDidClickLink
=
new
Emitter
<
URI
>
();
private
_onDidLoadContent
=
new
Emitter
<
{
stats
:
any
}
>
();
constructor
(
p
rivate
_p
arent
:
HTMLElement
,
private
_styleElement
:
Element
)
{
constructor
(
parent
:
HTMLElement
,
private
_styleElement
:
Element
)
{
this
.
_webview
=
<
any
>
document
.
createElement
(
'
webview
'
);
this
.
_webview
.
style
.
width
=
'
100%
'
;
...
...
@@ -96,7 +96,9 @@ export default class Webview {
})
];
this
.
_parent
.
appendChild
(
this
.
_webview
);
if
(
parent
)
{
parent
.
appendChild
(
this
.
_webview
);
}
}
dispose
():
void
{
...
...
@@ -109,6 +111,10 @@ export default class Webview {
}
}
get
domNode
():
HTMLElement
{
return
this
.
_webview
;
}
get
onDidClickLink
():
Event
<
URI
>
{
return
this
.
_onDidClickLink
.
event
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录