Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
3cc9e7f3
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,发现更多精彩内容 >>
提交
3cc9e7f3
编写于
3月 01, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes Microsoft/monaco-editor#385
上级
0ff45fcd
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
87 addition
and
80 deletion
+87
-80
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
+77
-76
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+8
-4
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+2
-0
未找到文件。
src/vs/editor/browser/standalone/standaloneCodeEditor.ts
浏览文件 @
3cc9e7f3
...
...
@@ -54,28 +54,29 @@ export interface IStandaloneDiffEditor extends IDiffEditor {
addCommand
(
keybinding
:
number
,
handler
:
ICommandHandler
,
context
:
string
):
string
;
createContextKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IContextKey
<
T
>
;
addAction
(
descriptor
:
IActionDescriptor
):
IDisposable
;
getOriginalEditor
():
IStandaloneCodeEditor
;
getModifiedEditor
():
IStandaloneCodeEditor
;
}
let
LAST_GENERATED_COMMAND_ID
=
0
;
export
class
StandaloneEditor
extends
CodeEditor
implements
IStandaloneCodeEditor
{
/**
* A code editor to be used both by the standalone editor and the standalone diff editor.
*/
export
class
StandaloneCodeEditor
extends
CodeEditor
implements
IStandaloneCodeEditor
{
private
_standaloneKeybindingService
:
StandaloneKeybindingService
;
private
_standaloneColorService
:
IStandaloneColorService
;
private
_contextViewService
:
IEditorContextViewService
;
private
_ownsModel
:
boolean
;
private
_toDispose2
:
IDisposable
[];
constructor
(
domElement
:
HTMLElement
,
options
:
IEditorConstructionOptions
,
toDispose
:
IDisposable
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
ICommandService
commandService
:
ICommandService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IContextViewService
contextViewService
:
IContextViewService
,
@
IStandaloneColorService
standaloneColorService
:
IStandaloneColorService
)
{
options
=
options
||
{};
...
...
@@ -83,42 +84,11 @@ export class StandaloneEditor extends CodeEditor implements IStandaloneCodeEdito
options
.
theme
=
standaloneColorService
.
setTheme
(
options
.
theme
);
}
super
(
domElement
,
options
,
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
);
this
.
_standaloneColorService
=
standaloneColorService
;
this
.
_standaloneColorService
=
standaloneColorService
;
if
(
keybindingService
instanceof
StandaloneKeybindingService
)
{
this
.
_standaloneKeybindingService
=
keybindingService
;
}
this
.
_contextViewService
=
<
IEditorContextViewService
>
contextViewService
;
this
.
_toDispose2
=
[
toDispose
];
let
model
:
IModel
=
null
;
if
(
typeof
options
.
model
===
'
undefined
'
)
{
model
=
(
<
any
>
self
).
monaco
.
editor
.
createModel
(
options
.
value
||
''
,
options
.
language
||
'
text/plain
'
);
this
.
_ownsModel
=
true
;
}
else
{
model
=
options
.
model
;
delete
options
.
model
;
this
.
_ownsModel
=
false
;
}
this
.
_attachModel
(
model
);
if
(
model
)
{
let
e
:
IModelChangedEvent
=
{
oldModelUrl
:
null
,
newModelUrl
:
model
.
uri
};
this
.
emit
(
EventType
.
ModelChanged
,
e
);
}
}
public
dispose
():
void
{
super
.
dispose
();
this
.
_toDispose2
=
dispose
(
this
.
_toDispose2
);
}
public
destroy
():
void
{
this
.
dispose
();
}
public
updateOptions
(
newOptions
:
IEditorOptions
):
void
{
...
...
@@ -140,10 +110,6 @@ export class StandaloneEditor extends CodeEditor implements IStandaloneCodeEdito
}
public
createContextKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IContextKey
<
T
>
{
if
(
!
this
.
_standaloneKeybindingService
)
{
console
.
warn
(
'
Cannot create context key because the editor is configured with an unrecognized KeybindingService
'
);
return
null
;
}
return
this
.
_contextKeyService
.
createKey
(
key
,
defaultValue
);
}
...
...
@@ -170,6 +136,60 @@ export class StandaloneEditor extends CodeEditor implements IStandaloneCodeEdito
}
return
combinedDisposable
(
toDispose
);
}
}
export
class
StandaloneEditor
extends
StandaloneCodeEditor
implements
IStandaloneCodeEditor
{
private
_contextViewService
:
IEditorContextViewService
;
private
_ownsModel
:
boolean
;
private
_toDispose2
:
IDisposable
[];
constructor
(
domElement
:
HTMLElement
,
options
:
IEditorConstructionOptions
,
toDispose
:
IDisposable
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
ICommandService
commandService
:
ICommandService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
,
@
IContextViewService
contextViewService
:
IContextViewService
,
@
IStandaloneColorService
standaloneColorService
:
IStandaloneColorService
)
{
options
=
options
||
{};
super
(
domElement
,
options
,
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
,
keybindingService
,
standaloneColorService
);
this
.
_contextViewService
=
<
IEditorContextViewService
>
contextViewService
;
this
.
_toDispose2
=
[
toDispose
];
let
model
:
IModel
=
null
;
if
(
typeof
options
.
model
===
'
undefined
'
)
{
model
=
(
<
any
>
self
).
monaco
.
editor
.
createModel
(
options
.
value
||
''
,
options
.
language
||
'
text/plain
'
);
this
.
_ownsModel
=
true
;
}
else
{
model
=
options
.
model
;
delete
options
.
model
;
this
.
_ownsModel
=
false
;
}
this
.
_attachModel
(
model
);
if
(
model
)
{
let
e
:
IModelChangedEvent
=
{
oldModelUrl
:
null
,
newModelUrl
:
model
.
uri
};
this
.
emit
(
EventType
.
ModelChanged
,
e
);
}
}
public
dispose
():
void
{
super
.
dispose
();
this
.
_toDispose2
=
dispose
(
this
.
_toDispose2
);
}
public
destroy
():
void
{
this
.
dispose
();
}
_attachModel
(
model
:
IModel
):
void
{
super
.
_attachModel
(
model
);
...
...
@@ -225,46 +245,27 @@ export class StandaloneDiffEditor extends DiffEditorWidget implements IStandalon
this
.
dispose
();
}
protected
_createInnerEditor
(
instantiationService
:
IInstantiationService
,
container
:
HTMLElement
,
options
:
IEditorOptions
):
CodeEditor
{
return
instantiationService
.
createInstance
(
StandaloneCodeEditor
,
container
,
options
);
}
public
getOriginalEditor
():
IStandaloneCodeEditor
{
return
<
StandaloneCodeEditor
>
super
.
getOriginalEditor
();
}
public
getModifiedEditor
():
IStandaloneCodeEditor
{
return
<
StandaloneCodeEditor
>
super
.
getModifiedEditor
();
}
public
addCommand
(
keybinding
:
number
,
handler
:
ICommandHandler
,
context
:
string
):
string
{
if
(
!
this
.
_standaloneKeybindingService
)
{
console
.
warn
(
'
Cannot add command because the editor is configured with an unrecognized KeybindingService
'
);
return
null
;
}
let
commandId
=
'
DYNAMIC_
'
+
(
++
LAST_GENERATED_COMMAND_ID
);
let
whenExpression
=
IOSupport
.
readKeybindingWhen
(
context
);
this
.
_standaloneKeybindingService
.
addDynamicKeybinding
(
commandId
,
keybinding
,
handler
,
whenExpression
);
return
commandId
;
return
this
.
getModifiedEditor
().
addCommand
(
keybinding
,
handler
,
context
);
}
public
createContextKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IContextKey
<
T
>
{
if
(
!
this
.
_standaloneKeybindingService
)
{
console
.
warn
(
'
Cannot create context key because the editor is configured with an unrecognized KeybindingService
'
);
return
null
;
}
return
this
.
_contextKeyService
.
createKey
(
key
,
defaultValue
);
return
this
.
getModifiedEditor
().
createContextKey
(
key
,
defaultValue
);
}
public
addAction
(
descriptor
:
IActionDescriptor
):
IDisposable
{
let
addedAction
=
this
.
_addAction
(
descriptor
);
let
toDispose
=
[
addedAction
.
disposable
];
if
(
!
this
.
_standaloneKeybindingService
)
{
console
.
warn
(
'
Cannot add keybinding because the editor is configured with an unrecognized KeybindingService
'
);
return
null
;
}
if
(
Array
.
isArray
(
descriptor
.
keybindings
))
{
let
handler
:
ICommandHandler
=
(
ctx
)
=>
{
return
this
.
trigger
(
'
keyboard
'
,
descriptor
.
id
,
null
);
};
let
whenExpression
=
ContextKeyExpr
.
and
(
IOSupport
.
readKeybindingWhen
(
descriptor
.
precondition
),
IOSupport
.
readKeybindingWhen
(
descriptor
.
keybindingContext
),
);
toDispose
=
toDispose
.
concat
(
descriptor
.
keybindings
.
map
((
kb
)
=>
{
return
this
.
_standaloneKeybindingService
.
addDynamicKeybinding
(
addedAction
.
uniqueId
,
kb
,
handler
,
whenExpression
);
})
);
}
return
combinedDisposable
(
toDispose
);
return
this
.
getModifiedEditor
().
addAction
(
descriptor
);
}
}
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
3cc9e7f3
...
...
@@ -373,17 +373,21 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
}
private
_createLeftHandSideEditor
(
options
:
editorCommon
.
IDiffEditorOptions
,
instantiationService
:
IInstantiationService
):
void
{
this
.
originalEditor
=
instantiationService
.
createInstance
(
CodeEditor
,
this
.
_originalDomNode
,
this
.
_adjustOptionsForLeftHandSide
(
options
,
this
.
_originalIsEditable
));
this
.
originalEditor
=
this
.
_createInnerEditor
(
instantiationService
,
this
.
_originalDomNode
,
this
.
_adjustOptionsForLeftHandSide
(
options
,
this
.
_originalIsEditable
));
this
.
_toDispose
.
push
(
this
.
originalEditor
.
addBulkListener2
((
events
)
=>
this
.
_onOriginalEditorEvents
(
events
)));
this
.
_toDispose
.
push
(
this
.
addEmitter2
(
this
.
originalEditor
));
}
private
_createRightHandSideEditor
(
options
:
editorCommon
.
IDiffEditorOptions
,
instantiationService
:
IInstantiationService
):
void
{
this
.
modifiedEditor
=
instantiationService
.
createInstance
(
CodeEditor
,
this
.
_modifiedDomNode
,
this
.
_adjustOptionsForRightHandSide
(
options
));
this
.
modifiedEditor
=
this
.
_createInnerEditor
(
instantiationService
,
this
.
_modifiedDomNode
,
this
.
_adjustOptionsForRightHandSide
(
options
));
this
.
_toDispose
.
push
(
this
.
modifiedEditor
.
addBulkListener2
((
events
)
=>
this
.
_onModifiedEditorEvents
(
events
)));
this
.
_toDispose
.
push
(
this
.
addEmitter2
(
this
.
modifiedEditor
));
}
protected
_createInnerEditor
(
instantiationService
:
IInstantiationService
,
container
:
HTMLElement
,
options
:
editorCommon
.
IEditorOptions
):
CodeEditor
{
return
instantiationService
.
createInstance
(
CodeEditor
,
container
,
options
);
}
public
destroy
():
void
{
this
.
dispose
();
}
...
...
@@ -894,7 +898,7 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
return
clonedOptions
;
}
private
_adjustOptionsForLeftHandSide
(
options
:
editorCommon
.
IDiffEditorOptions
,
isEditable
:
boolean
):
editorCommon
.
I
Diff
EditorOptions
{
private
_adjustOptionsForLeftHandSide
(
options
:
editorCommon
.
IDiffEditorOptions
,
isEditable
:
boolean
):
editorCommon
.
IEditorOptions
{
let
result
=
this
.
_adjustOptionsForSubEditor
(
options
);
result
.
readOnly
=
!
isEditable
;
result
.
overviewRulerLanes
=
1
;
...
...
@@ -902,7 +906,7 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
return
result
;
}
private
_adjustOptionsForRightHandSide
(
options
:
editorCommon
.
IDiffEditorOptions
):
editorCommon
.
I
Diff
EditorOptions
{
private
_adjustOptionsForRightHandSide
(
options
:
editorCommon
.
IDiffEditorOptions
):
editorCommon
.
IEditorOptions
{
let
result
=
this
.
_adjustOptionsForSubEditor
(
options
);
result
.
revealHorizontalRightPadding
=
DefaultConfig
.
editor
.
revealHorizontalRightPadding
+
DiffEditorWidget
.
ENTIRE_DIFF_OVERVIEW_WIDTH
;
result
.
scrollbar
.
verticalHasArrows
=
false
;
...
...
src/vs/monaco.d.ts
浏览文件 @
3cc9e7f3
...
...
@@ -970,6 +970,8 @@ declare module monaco.editor {
addCommand
(
keybinding
:
number
,
handler
:
ICommandHandler
,
context
:
string
):
string
;
createContextKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IContextKey
<
T
>
;
addAction
(
descriptor
:
IActionDescriptor
):
IDisposable
;
getOriginalEditor
():
IStandaloneCodeEditor
;
getModifiedEditor
():
IStandaloneCodeEditor
;
}
export
interface
ICommandHandler
{
(...
args
:
any
[]):
void
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录