Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
17a6e236
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,发现更多精彩内容 >>
提交
17a6e236
编写于
3月 20, 2018
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
introduce simple widget editor. Use a command delegate so extensions do not intercept commands
上级
344e93c6
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
86 addition
and
30 deletion
+86
-30
src/vs/editor/browser/codeEditor.ts
src/vs/editor/browser/codeEditor.ts
+1
-1
src/vs/editor/browser/view/viewController.ts
src/vs/editor/browser/view/viewController.ts
+18
-20
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+3
-4
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+58
-2
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+3
-0
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
+1
-1
src/vs/editor/test/browser/testCodeEditor.ts
src/vs/editor/test/browser/testCodeEditor.ts
+1
-1
src/vs/workbench/parts/debug/electron-browser/replEditor.ts
src/vs/workbench/parts/debug/electron-browser/replEditor.ts
+1
-1
未找到文件。
src/vs/editor/browser/codeEditor.ts
浏览文件 @
17a6e236
...
...
@@ -24,7 +24,7 @@ export class CodeEditor extends CodeEditorWidget {
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
)
{
super
(
domElement
,
options
,
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
,
themeService
);
super
(
domElement
,
options
,
false
,
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
,
themeService
);
}
protected
_getContributions
():
IEditorContributionCtor
[]
{
...
...
src/vs/editor/browser/view/viewController.ts
浏览文件 @
17a6e236
...
...
@@ -7,9 +7,7 @@
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorMouseEvent
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IViewModel
}
from
'
vs/editor/common/viewModel/viewModel
'
;
import
{
ViewOutgoingEvents
}
from
'
vs/editor/browser/view/viewOutgoingEvents
'
;
import
{
CoreNavigationCommands
,
CoreEditorCommand
}
from
'
vs/editor/browser/controller/coreCommands
'
;
...
...
@@ -35,26 +33,35 @@ export interface IMouseDispatchData {
shiftKey
:
boolean
;
}
export
interface
ICommandDelegate
{
paste
(
source
:
string
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
:
string
[]):
void
;
type
(
source
:
string
,
text
:
string
):
void
;
replacePreviousChar
(
source
:
string
,
text
:
string
,
replaceCharCnt
:
number
):
void
;
compositionStart
(
source
:
string
):
void
;
compositionEnd
(
source
:
string
):
void
;
cut
(
source
:
string
):
void
;
}
export
class
ViewController
{
private
readonly
configuration
:
Configuration
;
private
readonly
viewModel
:
IViewModel
;
private
readonly
_execCoreEditorCommandFunc
:
ExecCoreEditorCommandFunc
;
private
readonly
outgoingEvents
:
ViewOutgoingEvents
;
private
readonly
command
Service
:
ICommandServic
e
;
private
readonly
command
Delegate
:
ICommandDelegat
e
;
constructor
(
configuration
:
Configuration
,
viewModel
:
IViewModel
,
execCommandFunc
:
ExecCoreEditorCommandFunc
,
outgoingEvents
:
ViewOutgoingEvents
,
command
Service
:
ICommandServic
e
command
Delegate
:
ICommandDelegat
e
)
{
this
.
configuration
=
configuration
;
this
.
viewModel
=
viewModel
;
this
.
_execCoreEditorCommandFunc
=
execCommandFunc
;
this
.
outgoingEvents
=
outgoingEvents
;
this
.
command
Service
=
commandServic
e
;
this
.
command
Delegate
=
commandDelegat
e
;
}
private
_execMouseCommand
(
editorCommand
:
CoreEditorCommand
,
args
:
any
):
void
{
...
...
@@ -63,36 +70,27 @@ export class ViewController {
}
public
paste
(
source
:
string
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
:
string
[]):
void
{
this
.
commandService
.
executeCommand
(
editorCommon
.
Handler
.
Paste
,
{
text
:
text
,
pasteOnNewLine
:
pasteOnNewLine
,
multicursorText
:
multicursorText
});
this
.
commandDelegate
.
paste
(
source
,
text
,
pasteOnNewLine
,
multicursorText
);
}
public
type
(
source
:
string
,
text
:
string
):
void
{
this
.
commandService
.
executeCommand
(
editorCommon
.
Handler
.
Type
,
{
text
:
text
});
this
.
commandDelegate
.
type
(
source
,
text
);
}
public
replacePreviousChar
(
source
:
string
,
text
:
string
,
replaceCharCnt
:
number
):
void
{
this
.
commandService
.
executeCommand
(
editorCommon
.
Handler
.
ReplacePreviousChar
,
{
text
:
text
,
replaceCharCnt
:
replaceCharCnt
});
this
.
commandDelegate
.
replacePreviousChar
(
source
,
text
,
replaceCharCnt
);
}
public
compositionStart
(
source
:
string
):
void
{
this
.
command
Service
.
executeCommand
(
editorCommon
.
Handler
.
CompositionStart
,
{}
);
this
.
command
Delegate
.
compositionStart
(
source
);
}
public
compositionEnd
(
source
:
string
):
void
{
this
.
command
Service
.
executeCommand
(
editorCommon
.
Handler
.
CompositionEnd
,
{}
);
this
.
command
Delegate
.
compositionEnd
(
source
);
}
public
cut
(
source
:
string
):
void
{
this
.
command
Service
.
executeCommand
(
editorCommon
.
Handler
.
Cut
,
{}
);
this
.
command
Delegate
.
cut
(
source
);
}
public
setSelection
(
source
:
string
,
modelSelection
:
Selection
):
void
{
...
...
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
17a6e236
...
...
@@ -8,14 +8,13 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
FastDomNode
,
createFastDomNode
}
from
'
vs/base/browser/fastDomNode
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ViewEventHandler
}
from
'
vs/editor/common/viewModel/viewEventHandler
'
;
import
{
Configuration
}
from
'
vs/editor/browser/config/configuration
'
;
import
{
TextAreaHandler
,
ITextAreaHandlerHelper
}
from
'
vs/editor/browser/controller/textAreaHandler
'
;
import
{
PointerHandler
}
from
'
vs/editor/browser/controller/pointerHandler
'
;
import
*
as
editorBrowser
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ViewController
,
ExecCoreEditorCommandFunc
}
from
'
vs/editor/browser/view/viewController
'
;
import
{
ViewController
,
ExecCoreEditorCommandFunc
,
ICommandDelegate
}
from
'
vs/editor/browser/view/viewController
'
;
import
{
ViewEventDispatcher
}
from
'
vs/editor/common/view/viewEventDispatcher
'
;
import
{
ContentViewOverlays
,
MarginViewOverlays
}
from
'
vs/editor/browser/view/viewOverlays
'
;
import
{
ViewContentWidgets
}
from
'
vs/editor/browser/viewParts/contentWidgets/contentWidgets
'
;
...
...
@@ -93,7 +92,7 @@ export class View extends ViewEventHandler {
private
_renderAnimationFrame
:
IDisposable
;
constructor
(
command
Service
:
ICommandServic
e
,
command
Delegate
:
ICommandDelegat
e
,
configuration
:
Configuration
,
themeService
:
IThemeService
,
model
:
IViewModel
,
...
...
@@ -105,7 +104,7 @@ export class View extends ViewEventHandler {
this
.
_renderAnimationFrame
=
null
;
this
.
outgoingEvents
=
new
ViewOutgoingEvents
(
model
);
let
viewController
=
new
ViewController
(
configuration
,
model
,
execCoreEditorCommandFunc
,
this
.
outgoingEvents
,
command
Servic
e
);
let
viewController
=
new
ViewController
(
configuration
,
model
,
execCoreEditorCommandFunc
,
this
.
outgoingEvents
,
command
Delegat
e
);
// The event dispatcher will always go through _renderOnce before dispatching any events
this
.
eventDispatcher
=
new
ViewEventDispatcher
((
callback
:
()
=>
void
)
=>
this
.
_renderOnce
(
callback
));
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
17a6e236
...
...
@@ -33,6 +33,7 @@ import { Color } from 'vs/base/common/color';
import
{
IMouseEvent
}
from
'
vs/base/browser/mouseEvent
'
;
import
{
ClassName
}
from
'
vs/editor/common/model/intervalTree
'
;
import
{
ITextModel
,
IModelDecorationOptions
}
from
'
vs/editor/common/model
'
;
import
{
ICommandDelegate
}
from
'
../view/viewController
'
;
export
abstract
class
CodeEditorWidget
extends
CommonCodeEditor
implements
editorBrowser
.
ICodeEditor
{
...
...
@@ -86,13 +87,14 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
constructor
(
domElement
:
HTMLElement
,
options
:
IEditorOptions
,
isSimpleWidget
:
boolean
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
ICodeEditorService
codeEditorService
:
ICodeEditorService
,
@
ICommandService
commandService
:
ICommandService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
)
{
super
(
domElement
,
options
,
instantiationService
,
contextKeyService
);
super
(
domElement
,
options
,
i
sSimpleWidget
,
i
nstantiationService
,
contextKeyService
);
this
.
_codeEditorService
=
codeEditorService
;
this
.
_commandService
=
commandService
;
this
.
_themeService
=
themeService
;
...
...
@@ -358,8 +360,62 @@ export abstract class CodeEditorWidget extends CommonCodeEditor implements edito
}
protected
_createView
():
void
{
let
commandDelegate
:
ICommandDelegate
;
if
(
this
.
isSimpleWidget
)
{
commandDelegate
=
{
paste
:
(
source
:
string
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
:
string
[])
=>
{
this
.
cursor
.
trigger
(
source
,
editorCommon
.
Handler
.
Paste
,
{
text
,
pasteOnNewLine
,
multicursorText
});
},
type
:
(
source
:
string
,
text
:
string
)
=>
{
this
.
cursor
.
trigger
(
source
,
editorCommon
.
Handler
.
Type
,
{
text
});
},
replacePreviousChar
:
(
source
:
string
,
text
:
string
,
replaceCharCnt
:
number
)
=>
{
this
.
cursor
.
trigger
(
source
,
editorCommon
.
Handler
.
ReplacePreviousChar
,
{
text
,
replaceCharCnt
});
},
compositionStart
:
(
source
:
string
)
=>
{
this
.
cursor
.
trigger
(
source
,
editorCommon
.
Handler
.
CompositionStart
,
undefined
);
},
compositionEnd
:
(
source
:
string
)
=>
{
this
.
cursor
.
trigger
(
source
,
editorCommon
.
Handler
.
CompositionEnd
,
undefined
);
},
cut
:
(
source
:
string
)
=>
{
this
.
cursor
.
trigger
(
source
,
editorCommon
.
Handler
.
Cut
,
undefined
);
}
};
}
else
{
commandDelegate
=
{
paste
:
(
source
:
string
,
text
:
string
,
pasteOnNewLine
:
boolean
,
multicursorText
:
string
[])
=>
{
this
.
_commandService
.
executeCommand
(
editorCommon
.
Handler
.
Paste
,
{
text
:
text
,
pasteOnNewLine
:
pasteOnNewLine
,
multicursorText
:
multicursorText
});
},
type
:
(
source
:
string
,
text
:
string
)
=>
{
this
.
_commandService
.
executeCommand
(
editorCommon
.
Handler
.
Type
,
{
text
:
text
});
},
replacePreviousChar
:
(
source
:
string
,
text
:
string
,
replaceCharCnt
:
number
)
=>
{
this
.
_commandService
.
executeCommand
(
editorCommon
.
Handler
.
ReplacePreviousChar
,
{
text
:
text
,
replaceCharCnt
:
replaceCharCnt
});
},
compositionStart
:
(
source
:
string
)
=>
{
this
.
_commandService
.
executeCommand
(
editorCommon
.
Handler
.
CompositionStart
,
{});
},
compositionEnd
:
(
source
:
string
)
=>
{
this
.
_commandService
.
executeCommand
(
editorCommon
.
Handler
.
CompositionEnd
,
{});
},
cut
:
(
source
:
string
)
=>
{
this
.
_commandService
.
executeCommand
(
editorCommon
.
Handler
.
Cut
,
{});
}
};
}
this
.
_view
=
new
View
(
this
.
_commandServic
e
,
commandDelegat
e
,
this
.
_configuration
,
this
.
_themeService
,
this
.
viewModel
,
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
17a6e236
...
...
@@ -93,6 +93,7 @@ export abstract class CommonCodeEditor extends Disposable {
protected
readonly
domElement
:
IContextKeyServiceTarget
;
protected
readonly
id
:
number
;
protected
readonly
_configuration
:
CommonEditorConfiguration
;
protected
readonly
isSimpleWidget
:
boolean
;
protected
_contributions
:
{
[
key
:
string
]:
editorCommon
.
IEditorContribution
;
};
protected
_actions
:
{
[
key
:
string
]:
editorCommon
.
IEditorAction
;
};
...
...
@@ -118,6 +119,7 @@ export abstract class CommonCodeEditor extends Disposable {
constructor
(
domElement
:
IContextKeyServiceTarget
,
options
:
editorOptions
.
IEditorOptions
,
isSimpleWidget
:
boolean
,
instantiationService
:
IInstantiationService
,
contextKeyService
:
IContextKeyService
)
{
...
...
@@ -126,6 +128,7 @@ export abstract class CommonCodeEditor extends Disposable {
this
.
id
=
(
++
EDITOR_ID
);
this
.
_decorationTypeKeysToIds
=
{};
this
.
_decorationTypeSubtypes
=
{};
this
.
isSimpleWidget
=
isSimpleWidget
;
options
=
options
||
{};
this
.
_configuration
=
this
.
_register
(
this
.
_createConfiguration
(
options
));
...
...
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
浏览文件 @
17a6e236
...
...
@@ -37,7 +37,7 @@ function createMockEditor(model: TextModel): TestCodeEditor {
[
IStorageService
,
NullStorageService
]
));
const
editor
=
new
TestCodeEditor
(
new
MockScopeLocation
(),
{},
instantiationService
,
contextKeyService
);
const
editor
=
new
TestCodeEditor
(
new
MockScopeLocation
(),
{},
false
,
instantiationService
,
contextKeyService
);
editor
.
setModel
(
model
);
return
editor
;
}
...
...
src/vs/editor/test/browser/testCodeEditor.ts
浏览文件 @
17a6e236
...
...
@@ -173,7 +173,7 @@ function _createTestCodeEditor(options: TestCodeEditorCreationOptions): TestCode
services
.
set
(
IContextKeyService
,
contextKeyService
);
let
instantiationService
=
new
InstantiationService
(
services
);
let
editor
=
new
TestCodeEditor
(
new
MockScopeLocation
(),
options
,
instantiationService
,
contextKeyService
);
let
editor
=
new
TestCodeEditor
(
new
MockScopeLocation
(),
options
,
false
,
instantiationService
,
contextKeyService
);
editor
.
setModel
(
options
.
model
);
return
editor
;
}
src/vs/workbench/parts/debug/electron-browser/replEditor.ts
浏览文件 @
17a6e236
...
...
@@ -30,7 +30,7 @@ export class ReplInputEditor extends CodeEditorWidget {
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
)
{
super
(
domElement
,
options
,
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
,
themeService
);
super
(
domElement
,
options
,
true
,
instantiationService
,
codeEditorService
,
commandService
,
contextKeyService
,
themeService
);
}
protected
_getContributions
():
IEditorContributionCtor
[]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录