Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ceaa4ea2
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,发现更多精彩内容 >>
提交
ceaa4ea2
编写于
5月 21, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add typed listeners to the editor
上级
868570c8
变更
56
隐藏空白更改
内联
并排
Showing
56 changed file
with
364 addition
and
228 deletion
+364
-228
src/vs/base/common/eventEmitter.ts
src/vs/base/common/eventEmitter.ts
+0
-2
src/vs/base/parts/tree/browser/tree.ts
src/vs/base/parts/tree/browser/tree.ts
+2
-0
src/vs/editor/browser/editorBrowser.ts
src/vs/editor/browser/editorBrowser.ts
+10
-0
src/vs/editor/browser/view/viewController.ts
src/vs/editor/browser/view/viewController.ts
+3
-3
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+1
-8
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+30
-1
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+38
-13
src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts
src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts
+2
-2
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+44
-7
src/vs/editor/common/editorActionEnablement.ts
src/vs/editor/common/editorActionEnablement.ts
+10
-10
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+27
-2
src/vs/editor/contrib/accessibility/browser/accessibility.ts
src/vs/editor/contrib/accessibility/browser/accessibility.ts
+2
-2
src/vs/editor/contrib/clipboard/browser/clipboard.ts
src/vs/editor/contrib/clipboard/browser/clipboard.ts
+1
-1
src/vs/editor/contrib/codelens/browser/codelens.ts
src/vs/editor/contrib/codelens/browser/codelens.ts
+7
-5
src/vs/editor/contrib/color/browser/color.ts
src/vs/editor/contrib/color/browser/color.ts
+4
-4
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
+3
-3
src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts
...itor/contrib/defineKeybinding/browser/defineKeybinding.ts
+3
-3
src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts
src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts
+5
-5
src/vs/editor/contrib/find/browser/findWidget.ts
src/vs/editor/contrib/find/browser/findWidget.ts
+3
-3
src/vs/editor/contrib/find/common/findController.ts
src/vs/editor/contrib/find/common/findController.ts
+3
-3
src/vs/editor/contrib/find/common/findModel.ts
src/vs/editor/contrib/find/common/findModel.ts
+2
-2
src/vs/editor/contrib/folding/browser/folding.ts
src/vs/editor/contrib/folding/browser/folding.ts
+6
-6
src/vs/editor/contrib/format/common/formatActions.ts
src/vs/editor/contrib/format/common/formatActions.ts
+4
-4
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
...editor/contrib/goToDeclaration/browser/goToDeclaration.ts
+13
-9
src/vs/editor/contrib/gotoError/browser/gotoError.ts
src/vs/editor/contrib/gotoError/browser/gotoError.ts
+3
-3
src/vs/editor/contrib/hover/browser/hover.ts
src/vs/editor/contrib/hover/browser/hover.ts
+11
-7
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
+3
-3
src/vs/editor/contrib/iPadShowKeyboard/browser/iPadShowKeyboard.ts
...itor/contrib/iPadShowKeyboard/browser/iPadShowKeyboard.ts
+2
-2
src/vs/editor/contrib/links/browser/links.ts
src/vs/editor/contrib/links/browser/links.ts
+31
-27
src/vs/editor/contrib/outlineMarker/browser/outlineMarker.ts
src/vs/editor/contrib/outlineMarker/browser/outlineMarker.ts
+4
-4
src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts
...tor/contrib/parameterHints/browser/parameterHintsModel.ts
+4
-4
src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts
...or/contrib/parameterHints/browser/parameterHintsWidget.ts
+3
-3
src/vs/editor/contrib/quickFix/browser/quickFixModel.ts
src/vs/editor/contrib/quickFix/browser/quickFixModel.ts
+4
-4
src/vs/editor/contrib/quickFix/browser/quickFixSelectionWidget.ts
...ditor/contrib/quickFix/browser/quickFixSelectionWidget.ts
+2
-2
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
...r/contrib/referenceSearch/browser/referencesController.ts
+2
-2
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
...ditor/contrib/referenceSearch/browser/referencesWidget.ts
+3
-3
src/vs/editor/contrib/rename/browser/renameInputField.ts
src/vs/editor/contrib/rename/browser/renameInputField.ts
+3
-3
src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts
...selectionClipboard/electron-browser/selectionClipboard.ts
+4
-4
src/vs/editor/contrib/smartSelect/common/smartSelect.ts
src/vs/editor/contrib/smartSelect/common/smartSelect.ts
+2
-2
src/vs/editor/contrib/snippet/common/snippet.ts
src/vs/editor/contrib/snippet/common/snippet.ts
+5
-5
src/vs/editor/contrib/suggest/browser/suggest.ts
src/vs/editor/contrib/suggest/browser/suggest.ts
+4
-4
src/vs/editor/contrib/suggest/browser/suggestModel.ts
src/vs/editor/contrib/suggest/browser/suggestModel.ts
+4
-4
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
+5
-5
src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts
.../editor/contrib/wordHighlighter/common/wordHighlighter.ts
+3
-3
src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
+2
-2
src/vs/platform/editor/common/editor.ts
src/vs/platform/editor/common/editor.ts
+5
-1
src/vs/platform/jsonschemas/common/jsonContributionRegistry.ts
...s/platform/jsonschemas/common/jsonContributionRegistry.ts
+2
-2
src/vs/workbench/api/node/mainThreadEditors.ts
src/vs/workbench/api/node/mainThreadEditors.ts
+6
-6
src/vs/workbench/browser/composite.ts
src/vs/workbench/browser/composite.ts
+2
-2
src/vs/workbench/browser/parts/editor/textEditor.ts
src/vs/workbench/browser/parts/editor/textEditor.ts
+5
-5
src/vs/workbench/common/composite.ts
src/vs/workbench/common/composite.ts
+2
-2
src/vs/workbench/parts/debug/browser/breakpointWidget.ts
src/vs/workbench/parts/debug/browser/breakpointWidget.ts
+1
-2
src/vs/workbench/parts/debug/browser/debugEditorContribution.ts
.../workbench/parts/debug/browser/debugEditorContribution.ts
+9
-9
src/vs/workbench/parts/debug/browser/debugHover.ts
src/vs/workbench/parts/debug/browser/debugHover.ts
+2
-2
src/vs/workbench/parts/git/browser/gitActions.contribution.ts
...vs/workbench/parts/git/browser/gitActions.contribution.ts
+2
-2
src/vs/workbench/parts/git/browser/gitEditorContributions.ts
src/vs/workbench/parts/git/browser/gitEditorContributions.ts
+1
-1
未找到文件。
src/vs/base/common/eventEmitter.ts
浏览文件 @
ceaa4ea2
...
...
@@ -39,8 +39,6 @@ export interface IEventEmitter extends IDisposable {
addOneTimeDisposableListener
(
eventType
:
string
,
listener
:
ListenerCallback
):
IDisposable
;
addBulkListener2
(
listener
:
BulkListenerCallback
):
IDisposable
;
addEmitter2
(
eventEmitter
:
IEventEmitter
):
IDisposable
;
emit
(
eventType
:
string
,
data
?:
any
):
void
;
}
export
interface
IListenersMap
{
...
...
src/vs/base/parts/tree/browser/tree.ts
浏览文件 @
ceaa4ea2
...
...
@@ -14,6 +14,8 @@ import { ScrollbarVisibility } from 'vs/base/browser/ui/scrollbar/scrollableElem
export
interface
ITree
extends
Events
.
IEventEmitter
{
emit
(
eventType
:
string
,
data
?:
any
):
void
;
/**
* Returns the tree's DOM element.
*/
...
...
src/vs/editor/browser/editorBrowser.ts
浏览文件 @
ceaa4ea2
...
...
@@ -466,6 +466,16 @@ export interface IOverviewRuler {
*/
export
interface
ICodeEditor
extends
editorCommon
.
ICommonCodeEditor
{
onMouseUp
(
listener
:
(
e
:
IEditorMouseEvent
)
=>
void
):
IDisposable
;
onMouseDown
(
listener
:
(
e
:
IEditorMouseEvent
)
=>
void
):
IDisposable
;
onContextMenu
(
listener
:
(
e
:
IEditorMouseEvent
)
=>
void
):
IDisposable
;
onMouseMove
(
listener
:
(
e
:
IEditorMouseEvent
)
=>
void
):
IDisposable
;
onMouseLeave
(
listener
:
(
e
:
IEditorMouseEvent
)
=>
void
):
IDisposable
;
onKeyUp
(
listener
:
(
e
:
IKeyboardEvent
)
=>
void
):
IDisposable
;
onKeyDown
(
listener
:
(
e
:
IKeyboardEvent
)
=>
void
):
IDisposable
;
onDidLayoutChange
(
listener
:
(
e
:
editorCommon
.
EditorLayoutInfo
)
=>
void
):
IDisposable
;
onDidScrollChange
(
listener
:
(
e
:
editorCommon
.
IScrollEvent
)
=>
void
):
IDisposable
;
/**
* Returns the editor's dom node
*/
...
...
src/vs/editor/browser/view/viewController.ts
浏览文件 @
ceaa4ea2
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
I
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -20,13 +20,13 @@ export class ViewController implements IViewController {
private
viewModel
:
IViewModel
;
private
triggerCursorHandler
:
TriggerCursorHandler
;
private
outgoingEventBus
:
I
EventEmitter
;
private
outgoingEventBus
:
EventEmitter
;
private
keybindingService
:
IKeybindingService
;
constructor
(
viewModel
:
IViewModel
,
triggerCursorHandler
:
TriggerCursorHandler
,
outgoingEventBus
:
I
EventEmitter
,
outgoingEventBus
:
EventEmitter
,
keybindingService
:
IKeybindingService
)
{
this
.
viewModel
=
viewModel
;
...
...
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
ceaa4ea2
...
...
@@ -457,14 +457,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
return
false
;
}
public
onScrollChanged
(
e
:
editorCommon
.
IScrollEvent
):
boolean
{
this
.
outgoingEventBus
.
emit
(
'
scroll
'
,
{
scrollTop
:
this
.
layoutProvider
.
getScrollTop
(),
scrollLeft
:
this
.
layoutProvider
.
getScrollLeft
()
});
this
.
outgoingEventBus
.
emit
(
'
scrollSize
'
,
{
scrollWidth
:
this
.
layoutProvider
.
getScrollWidth
(),
scrollHeight
:
this
.
layoutProvider
.
getScrollHeight
()
});
this
.
outgoingEventBus
.
emit
(
'
scroll
'
,
e
);
return
false
;
}
public
onViewFocusChanged
(
isFocused
:
boolean
):
boolean
{
...
...
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -25,11 +25,40 @@ import * as editorBrowser from 'vs/editor/browser/editorBrowser';
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
Colorizer
}
from
'
vs/editor/browser/standalone/colorizer
'
;
import
{
View
}
from
'
vs/editor/browser/view/viewImpl
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
export
class
CodeEditorWidget
extends
CommonCodeEditor
implements
editorBrowser
.
ICodeEditor
{
public
onMouseUp
(
listener
:
(
e
:
editorBrowser
.
IEditorMouseEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
MouseUp
,
listener
);
}
public
onMouseDown
(
listener
:
(
e
:
editorBrowser
.
IEditorMouseEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
listener
);
}
public
onContextMenu
(
listener
:
(
e
:
editorBrowser
.
IEditorMouseEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ContextMenu
,
listener
);
}
public
onMouseMove
(
listener
:
(
e
:
editorBrowser
.
IEditorMouseEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
MouseMove
,
listener
);
}
public
onMouseLeave
(
listener
:
(
e
:
editorBrowser
.
IEditorMouseEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
MouseLeave
,
listener
);
}
public
onKeyUp
(
listener
:
(
e
:
IKeyboardEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
KeyUp
,
listener
);
}
public
onKeyDown
(
listener
:
(
e
:
IKeyboardEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
KeyDown
,
listener
);
}
public
onDidLayoutChange
(
listener
:
(
e
:
editorCommon
.
EditorLayoutInfo
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
EditorLayout
,
listener
);
}
public
onDidScrollChange
(
listener
:
(
e
:
editorCommon
.
IScrollEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
'
scroll
'
,
listener
);
}
protected
domElement
:
HTMLElement
;
private
_focusTracker
:
CodeEditorWidgetFocusTracker
;
...
...
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -26,11 +26,6 @@ import {CodeEditorWidget} from 'vs/editor/browser/widget/codeEditorWidget';
import
{
ViewLineToken
,
ViewLineTokens
}
from
'
vs/editor/common/core/viewLineToken
'
;
import
{
Configuration
}
from
'
vs/editor/browser/config/configuration
'
;
interface
IEditorScrollEvent
{
scrollLeft
:
number
;
scrollTop
:
number
;
}
interface
IEditorDiffDecorations
{
decorations
:
editorCommon
.
IModelDeltaDecoration
[];
overviewZones
:
editorBrowser
.
OverviewRulerZone
[];
...
...
@@ -129,6 +124,31 @@ var DIFF_EDITOR_ID = 0;
export
class
DiffEditorWidget
extends
EventEmitter
implements
editorBrowser
.
IDiffEditor
{
public
onDidModelContentChange
(
listener
:
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelContentChanged
,
listener
);
}
public
onDidModelModeChange
(
listener
:
(
e
:
editorCommon
.
IModelModeChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
listener
);
}
public
onDidModelOptionsChange
(
listener
:
(
e
:
editorCommon
.
IModelOptionsChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelOptionsChanged
,
listener
);
}
public
onDidConfigurationChange
(
listener
:
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
listener
);
}
public
onDidCursorPositionChange
(
listener
:
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
listener
);
}
public
onDidCursorSelectionChange
(
listener
:
(
e
:
editorCommon
.
ICursorSelectionChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
CursorSelectionChanged
,
listener
);
}
public
onDidDispose
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
Disposed
,
listener
);
}
public
onDidUpdateDiff
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
DiffUpdated
,
listener
);
}
private
static
ONE_OVERVIEW_WIDTH
=
15
;
public
static
ENTIRE_DIFF_OVERVIEW_WIDTH
=
30
;
private
static
UPDATE_DIFF_DECORATIONS_DELAY
=
200
;
// ms
...
...
@@ -355,6 +375,8 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
this
.
_strategy
.
dispose
();
this
.
emit
(
editorCommon
.
EventType
.
Disposed
);
super
.
dispose
();
}
...
...
@@ -674,7 +696,7 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
var
changed
=
false
;
for
(
var
i
=
0
;
!
changed
&&
i
<
events
.
length
;
i
++
)
{
var
type
=
events
[
i
].
getType
();
changed
=
changed
||
type
===
'
change
'
||
type
===
editorCommon
.
EventType
.
ModelModeChanged
;
changed
=
changed
||
type
===
editorCommon
.
EventType
.
ModelContentChanged
||
type
===
editorCommon
.
EventType
.
ModelModeChanged
;
}
if
(
changed
&&
this
.
_isVisible
)
{
// Clear previous timeout if necessary
...
...
@@ -704,9 +726,6 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
this
.
_onModifiedEditorScroll
(
events
[
i
].
getData
());
this
.
_layoutOverviewViewport
();
}
if
(
events
[
i
].
getType
()
===
'
scrollSize
'
)
{
this
.
_layoutOverviewViewport
();
}
if
(
events
[
i
].
getType
()
===
'
viewLayoutChanged
'
)
{
this
.
_layoutOverviewViewport
();
}
...
...
@@ -747,7 +766,7 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
{
this
.
_lineChanges
=
result
;
this
.
_updateDecorationsRunner
.
schedule
();
this
.
emit
(
editorCommon
.
EventType
.
DiffUpdated
,
{
editor
:
this
,
lineChanges
:
result
});
this
.
emit
(
editorCommon
.
EventType
.
DiffUpdated
,
{
});
}
},
(
error
)
=>
{
if
(
currentToken
===
this
.
_diffComputationToken
...
...
@@ -810,7 +829,10 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
return
result
;
}
private
_onOriginalEditorScroll
(
e
:
IEditorScrollEvent
):
void
{
private
_onOriginalEditorScroll
(
e
:
editorCommon
.
IScrollEvent
):
void
{
if
(
!
e
.
scrollTopChanged
&&
!
e
.
scrollLeftChanged
)
{
return
;
}
if
(
this
.
_isHandlingScrollEvent
)
{
return
;
}
...
...
@@ -822,7 +844,10 @@ export class DiffEditorWidget extends EventEmitter implements editorBrowser.IDif
this
.
_isHandlingScrollEvent
=
false
;
}
private
_onModifiedEditorScroll
(
e
:
IEditorScrollEvent
):
void
{
private
_onModifiedEditorScroll
(
e
:
editorCommon
.
IScrollEvent
):
void
{
if
(
!
e
.
scrollTopChanged
&&
!
e
.
scrollLeftChanged
)
{
return
;
}
if
(
this
.
_isHandlingScrollEvent
)
{
return
;
}
...
...
@@ -1594,7 +1619,7 @@ class DiffEdtorWidgetInline extends DiffEditorWidgetStyle implements IDiffEditor
this
.
decorationsLeft
=
dataSource
.
getOriginalEditor
().
getLayoutInfo
().
decorationsLeft
;
this
.
toDispose
=
[];
this
.
toDispose
.
push
(
dataSource
.
getOriginalEditor
().
addListener2
(
editorCommon
.
EventType
.
EditorLayout
,
(
layoutInfo
:
editorCommon
.
EditorLayoutInfo
)
=>
{
this
.
toDispose
.
push
(
dataSource
.
getOriginalEditor
().
onDidLayoutChange
(
(
layoutInfo
:
editorCommon
.
EditorLayoutInfo
)
=>
{
if
(
this
.
decorationsLeft
!==
layoutInfo
.
decorationsLeft
)
{
this
.
decorationsLeft
=
layoutInfo
.
decorationsLeft
;
dataSource
.
relayoutEditors
();
...
...
src/vs/editor/browser/widget/embeddedCodeEditorWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
EventType
,
ICodeEditorWidgetCreationOptions
,
IConfigurationChangedEvent
,
IEditorOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorWidgetCreationOptions
,
IConfigurationChangedEvent
,
IEditorOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CodeEditorWidget
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
...
...
@@ -35,7 +35,7 @@ export class EmbeddedCodeEditorWidget extends CodeEditorWidget {
// Overwrite parent's options
super
.
updateOptions
(
this
.
_overwriteOptions
);
this
.
_lifetimeDispose
.
push
(
parentEditor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
this
.
_onParentConfigurationChanged
(
e
)));
this
.
_lifetimeDispose
.
push
(
parentEditor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
this
.
_onParentConfigurationChanged
(
e
)));
}
public
getParentEditor
():
ICodeEditor
{
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
ceaa4ea2
...
...
@@ -36,6 +36,49 @@ var EDITOR_ID = 0;
export
abstract
class
CommonCodeEditor
extends
EventEmitter
implements
IActionProvider
,
editorCommon
.
ICommonCodeEditor
{
public
onDidModelContentChange
(
listener
:
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelContentChanged
,
listener
);
}
public
onDidModelModeChange
(
listener
:
(
e
:
editorCommon
.
IModelModeChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
listener
);
}
public
onDidModelOptionsChange
(
listener
:
(
e
:
editorCommon
.
IModelOptionsChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelOptionsChanged
,
listener
);
}
public
onDidModelModeSupportChange
(
listener
:
(
e
:
editorCommon
.
IModeSupportChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelModeSupportChanged
,
listener
);
}
public
onDidModelDecorationsChange
(
listener
:
(
e
:
editorCommon
.
IModelDecorationsChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
listener
);
}
public
onDidConfigurationChange
(
listener
:
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
listener
);
}
public
onDidModelChange
(
listener
:
(
e
:
editorCommon
.
IModelChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
listener
);
}
public
onDidCursorPositionChange
(
listener
:
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
listener
);
}
public
onDidCursorSelectionChange
(
listener
:
(
e
:
editorCommon
.
ICursorSelectionChangedEvent
)
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
CursorSelectionChanged
,
listener
);
}
public
onDidEditorTextFocus
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
EditorTextFocus
,
listener
);
}
public
onDidEditorTextBlur
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
EditorTextBlur
,
listener
);
}
public
onDidEditorFocus
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
EditorFocus
,
listener
);
}
public
onDidEditorBlur
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
EditorBlur
,
listener
);
}
public
onDidDispose
(
listener
:
()
=>
void
):
IDisposable
{
return
this
.
addListener2
(
editorCommon
.
EventType
.
Disposed
,
listener
);
}
protected
domElement
:
IKeybindingScopeLocation
;
protected
id
:
number
;
...
...
@@ -153,7 +196,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr
this
.
_postDetachModelCleanup
(
this
.
_detachModel
());
this
.
_configuration
.
dispose
();
this
.
_keybindingService
.
dispose
();
this
.
emit
(
editorCommon
.
EventType
.
Disposed
,
{}
);
this
.
emit
(
editorCommon
.
EventType
.
Disposed
);
super
.
dispose
();
}
...
...
@@ -750,10 +793,6 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr
this
.
emit
(
'
scroll
'
,
e
);
break
;
case
'
scrollSize
'
:
this
.
emit
(
'
scrollSize
'
,
e
);
break
;
case
editorCommon
.
EventType
.
ViewFocusLost
:
this
.
emit
(
editorCommon
.
EventType
.
EditorTextBlur
);
break
;
...
...
@@ -817,9 +856,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr
break
;
case
editorCommon
.
EventType
.
ModelContentChanged
:
// TODO@Alex
this
.
emit
(
editorCommon
.
EventType
.
ModelContentChanged
,
e
);
this
.
emit
(
'
change
'
,
{});
break
;
case
editorCommon
.
EventType
.
ModelOptionsChanged
:
...
...
src/vs/editor/common/editorActionEnablement.ts
浏览文件 @
ceaa4ea2
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
EventType
,
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
export
enum
Behaviour
{
TextFocus
=
1
<<
0
,
...
...
@@ -115,15 +115,15 @@ class InternalEnablementState extends CachingEnablementState {
this
.
_callOnDispose
=
[];
if
(
this
.
_behaviour
&
Behaviour
.
TextFocus
)
{
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
EditorTextFocus
,
()
=>
this
.
_updateTextFocus
(
true
)));
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
EditorTextBlur
,
()
=>
this
.
_updateTextFocus
(
false
)));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidEditorTextFocus
(
()
=>
this
.
_updateTextFocus
(
true
)));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidEditorTextBlur
(
()
=>
this
.
_updateTextFocus
(
false
)));
}
if
(
this
.
_behaviour
&
Behaviour
.
WidgetFocus
)
{
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
EditorFocus
,
()
=>
this
.
_updateWidgetFocus
(
true
)));
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
EditorBlur
,
()
=>
this
.
_updateWidgetFocus
(
false
)));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidEditorFocus
(
()
=>
this
.
_updateWidgetFocus
(
true
)));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidEditorBlur
(
()
=>
this
.
_updateWidgetFocus
(
false
)));
}
if
(
this
.
_behaviour
&
Behaviour
.
Writeable
)
{
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
)
=>
this
.
_update
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidConfigurationChange
(
(
e
)
=>
this
.
_update
()));
}
}
...
...
@@ -174,12 +174,12 @@ class DescentEnablementState extends CachingEnablementState {
super
();
if
(
behaviour
&
Behaviour
.
UpdateOnModelChange
)
{
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ModelChanged
,
()
=>
this
.
reset
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ModelModeChanged
,
()
=>
this
.
reset
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ModelModeSupportChanged
,
()
=>
this
.
reset
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
this
.
reset
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidModelModeChange
(
()
=>
this
.
reset
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidModelModeSupportChange
(
()
=>
this
.
reset
()));
}
if
(
behaviour
&
Behaviour
.
UpdateOnCursorPositionChange
)
{
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
CursorPositionChanged
,
()
=>
this
.
reset
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidCursorPositionChange
(
()
=>
this
.
reset
()));
}
}
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
ceaa4ea2
...
...
@@ -5,7 +5,6 @@
'
use strict
'
;
import
{
IAction
}
from
'
vs/base/common/actions
'
;
import
Event
from
'
vs/base/common/event
'
;
import
{
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
...
@@ -16,6 +15,10 @@ import {ViewLineToken} from 'vs/editor/common/core/viewLineToken';
import
{
ScrollbarVisibility
}
from
'
vs/base/browser/ui/scrollbar/scrollableElementOptions
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
interface
Event
<
T
>
{
(
listener
:
(
e
:
T
)
=>
any
,
thisArg
?:
any
):
IDisposable
;
}
// --- position & range
/**
...
...
@@ -3046,7 +3049,17 @@ export interface ICommonEditorContributionDescriptor {
/**
* An editor.
*/
export
interface
IEditor
extends
IEventEmitter
{
export
interface
IEditor
{
onDidModelContentChange
(
listener
:
(
e
:
IModelContentChangedEvent
)
=>
void
):
IDisposable
;
onDidModelModeChange
(
listener
:
(
e
:
IModelModeChangedEvent
)
=>
void
):
IDisposable
;
onDidModelOptionsChange
(
listener
:
(
e
:
IModelOptionsChangedEvent
)
=>
void
):
IDisposable
;
onDidConfigurationChange
(
listener
:
(
e
:
IConfigurationChangedEvent
)
=>
void
):
IDisposable
;
onDidCursorPositionChange
(
listener
:
(
e
:
ICursorPositionChangedEvent
)
=>
void
):
IDisposable
;
onDidCursorSelectionChange
(
listener
:
(
e
:
ICursorSelectionChangedEvent
)
=>
void
):
IDisposable
;
onDidDispose
(
listener
:
()
=>
void
):
IDisposable
;
dispose
():
void
;
getId
():
string
;
...
...
@@ -3319,6 +3332,16 @@ export interface IRangeWithMessage {
export
interface
ICommonCodeEditor
extends
IEditor
{
onDidModelChange
(
listener
:
(
e
:
IModelChangedEvent
)
=>
void
):
IDisposable
;
onDidModelModeSupportChange
(
listener
:
(
e
:
IModeSupportChangedEvent
)
=>
void
):
IDisposable
;
onDidModelDecorationsChange
(
listener
:
(
e
:
IModelDecorationsChangedEvent
)
=>
void
):
IDisposable
;
onDidEditorTextFocus
(
listener
:
()
=>
void
):
IDisposable
;
onDidEditorTextBlur
(
listener
:
()
=>
void
):
IDisposable
;
onDidEditorFocus
(
listener
:
()
=>
void
):
IDisposable
;
onDidEditorBlur
(
listener
:
()
=>
void
):
IDisposable
;
/**
* Returns true if this editor or one of its widgets has keyboard focus.
*/
...
...
@@ -3462,6 +3485,8 @@ export interface ICommonCodeEditor extends IEditor {
}
export
interface
ICommonDiffEditor
extends
IEditor
{
onDidUpdateDiff
(
listener
:
()
=>
void
):
IDisposable
;
/**
* Type the getModel() of IEditor.
*/
...
...
src/vs/editor/contrib/accessibility/browser/accessibility.ts
浏览文件 @
ceaa4ea2
...
...
@@ -21,7 +21,7 @@ import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegi
import
{
GlobalScreenReaderNVDA
}
from
'
vs/editor/common/config/commonEditorConfig
'
;
import
{
EditorAction
}
from
'
vs/editor/common/editorAction
'
;
import
{
Behaviour
}
from
'
vs/editor/common/editorActionEnablement
'
;
import
{
EventType
,
ICommonCodeEditor
,
IEditorActionDescriptorData
,
IEditorContribution
,
SHOW_ACCESSIBILITY_HELP_ACTION_ID
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
IEditorActionDescriptorData
,
IEditorContribution
,
SHOW_ACCESSIBILITY_HELP_ACTION_ID
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ICodeEditor
,
IOverlayWidget
,
IOverlayWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
...
...
@@ -91,7 +91,7 @@ class AccessibilityHelpWidget extends Widget implements IOverlayWidget {
this
.
_domNode
.
setAttribute
(
'
aria-hidden
'
,
'
true
'
);
this
.
_isVisible
=
false
;
this
.
_register
(
this
.
_editor
.
addListener2
(
EventType
.
EditorLayout
,
()
=>
{
this
.
_register
(
this
.
_editor
.
onDidLayoutChange
(
()
=>
{
if
(
this
.
_isVisible
)
{
this
.
_layout
();
}
...
...
src/vs/editor/contrib/clipboard/browser/clipboard.ts
浏览文件 @
ceaa4ea2
...
...
@@ -26,7 +26,7 @@ class ClipboardWritingAction extends EditorAction {
constructor
(
descriptor
:
editorCommon
.
IEditorActionDescriptorData
,
editor
:
editorCommon
.
ICommonCodeEditor
,
condition
:
Behaviour
)
{
super
(
descriptor
,
editor
,
condition
);
this
.
toUnhook
=
[];
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
CursorSelectionChanged
,
(
e
:
editorCommon
.
ICursorSelectionChangedEvent
)
=>
{
this
.
toUnhook
.
push
(
this
.
editor
.
onDidCursorSelectionChange
(
(
e
:
editorCommon
.
ICursorSelectionChangedEvent
)
=>
{
this
.
resetEnablementState
();
}));
}
...
...
src/vs/editor/contrib/codelens/browser/codelens.ts
浏览文件 @
ceaa4ea2
...
...
@@ -362,9 +362,9 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
this
.
_currentFindCodeLensSymbolsPromise
=
null
;
this
.
_modelChangeCounter
=
0
;
this
.
_globalToDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
onModelChange
()));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
this
.
onModelChange
()));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
{
this
.
_globalToDispose
.
push
(
this
.
_editor
.
onDidModelChange
(
()
=>
this
.
onModelChange
()));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
onDidModelModeChange
(
()
=>
this
.
onModelChange
()));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
onDidConfigurationChange
(
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
{
let
prevIsEnabled
=
this
.
_isEnabled
;
this
.
_isEnabled
=
this
.
_editor
.
getConfiguration
().
contribInfo
.
referenceInfos
;
if
(
prevIsEnabled
!==
this
.
_isEnabled
)
{
...
...
@@ -472,8 +472,10 @@ export class CodeLensContribution implements editorCommon.IEditorContribution {
scheduler
.
schedule
();
}
}));
this
.
_localToDispose
.
push
(
this
.
_editor
.
addListener2
(
'
scroll
'
,
(
e
)
=>
{
detectVisible
.
schedule
();
this
.
_localToDispose
.
push
(
this
.
_editor
.
onDidScrollChange
((
e
)
=>
{
if
(
e
.
scrollTopChanged
)
{
detectVisible
.
schedule
();
}
}));
this
.
_localToDispose
.
push
({
dispose
:
()
=>
{
...
...
src/vs/editor/contrib/color/browser/color.ts
浏览文件 @
ceaa4ea2
...
...
@@ -94,9 +94,9 @@ export class ColorContribution implements editorCommon.IEditorContribution {
this
.
_callOnDispose
.
push
(
this
.
_contentChangedScheduler
);
this
.
_callOnDispose
.
push
(
this
.
_decorationsChangedScheduler
);
this
.
_callOnDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
onModelChange
()));
this
.
_callOnDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
this
.
onModelChange
()));
this
.
_callOnDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeSupportChanged
,
(
e
:
editorCommon
.
IModeSupportChangedEvent
)
=>
{
this
.
_callOnDispose
.
push
(
this
.
_editor
.
onDidModelChange
(
()
=>
this
.
onModelChange
()));
this
.
_callOnDispose
.
push
(
this
.
_editor
.
onDidModelModeChange
(
()
=>
this
.
onModelChange
()));
this
.
_callOnDispose
.
push
(
this
.
_editor
.
onDidModelModeSupportChange
(
(
e
:
editorCommon
.
IModeSupportChangedEvent
)
=>
{
this
.
onModelChange
();
}));
...
...
@@ -172,7 +172,7 @@ export class ColorContribution implements editorCommon.IEditorContribution {
this
.
_currentFindColorDeclarationsPromise
=
null
;
}
});
this
.
_callOnModelChange
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelContentChanged
,
(
event
)
=>
this
.
_contentChangedScheduler
.
schedule
()));
this
.
_callOnModelChange
.
push
(
this
.
_editor
.
onDidModelContentChange
(
(
event
)
=>
this
.
_contentChangedScheduler
.
schedule
()));
this
.
_callOnModelChange
.
push
(
model
.
addListener2
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
(
event
)
=>
this
.
_decorationsChangedScheduler
.
schedule
()));
}
...
...
src/vs/editor/contrib/contextmenu/browser/contextmenu.ts
浏览文件 @
ceaa4ea2
...
...
@@ -17,7 +17,7 @@ import {IContextMenuService, IContextViewService} from 'vs/platform/contextview/
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
EditorAction
}
from
'
vs/editor/common/editorAction
'
;
import
{
Behaviour
}
from
'
vs/editor/common/editorActionEnablement
'
;
import
{
EventType
,
ICommonCodeEditor
,
IEditorActionDescriptorData
,
IEditorContribution
,
MouseTargetType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
IEditorActionDescriptorData
,
IEditorContribution
,
MouseTargetType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
...
...
@@ -49,8 +49,8 @@ class ContextMenuController implements IEditorContribution {
this
.
_contextMenuIsBeingShownCount
=
0
;
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
EventType
.
ContextMenu
,
(
e
:
IEditorMouseEvent
)
=>
this
.
_onContextMenu
(
e
)));
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
EventType
.
KeyDown
,
(
e
:
IKeyboardEvent
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
onContextMenu
(
(
e
:
IEditorMouseEvent
)
=>
this
.
_onContextMenu
(
e
)));
this
.
_toDispose
.
push
(
this
.
_editor
.
onKeyDown
(
(
e
:
IKeyboardEvent
)
=>
{
if
(
e
.
keyCode
===
KeyCode
.
ContextMenu
)
{
// Chrome is funny like that
e
.
preventDefault
();
...
...
src/vs/editor/contrib/defineKeybinding/browser/defineKeybinding.ts
浏览文件 @
ceaa4ea2
...
...
@@ -61,14 +61,14 @@ export class DefineKeybindingController implements editorCommon.IEditorContribut
this
.
_launchWidget
=
new
DefineKeybindingLauncherWidget
(
this
.
_editor
,
keybindingService
,
()
=>
this
.
launch
());
this
.
_defineWidget
=
new
DefineKeybindingWidget
(
this
.
_editor
,
keybindingService
,
(
keybinding
)
=>
this
.
_onAccepted
(
keybinding
));
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
(
e
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidConfigurationChange
(
(
e
)
=>
{
if
(
isInterestingEditorModel
(
this
.
_editor
))
{
this
.
_launchWidget
.
show
();
}
else
{
this
.
_launchWidget
.
hide
();
}
}));
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
(
e
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidModelChange
(
(
e
)
=>
{
if
(
isInterestingEditorModel
(
this
.
_editor
))
{
this
.
_launchWidget
.
show
();
}
else
{
...
...
@@ -374,7 +374,7 @@ class DefineKeybindingWidget implements IOverlayWidget {
let
htmlkb
=
this
.
_keybindingService
.
getHTMLLabelFor
(
this
.
_lastKeybinding
);
htmlkb
.
forEach
((
item
)
=>
this
.
_outputNode
.
appendChild
(
renderHtml
(
item
)));
}));
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
(
e
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidConfigurationChange
(
(
e
)
=>
{
if
(
this
.
_isVisible
)
{
this
.
_layout
();
}
...
...
src/vs/editor/contrib/diffNavigator/common/diffNavigator.ts
浏览文件 @
ceaa4ea2
...
...
@@ -8,7 +8,7 @@ import * as assert from 'vs/base/common/assert';
import
{
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
EventType
,
ICommonDiffEditor
,
ICursorPositionChangedEvent
,
IEditorRange
,
ILineChange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonDiffEditor
,
ICursorPositionChangedEvent
,
IEditorRange
,
ILineChange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
interface
IDiffRange
{
...
...
@@ -63,11 +63,11 @@ export class DiffNavigator extends EventEmitter {
this
.
revealFirst
=
this
.
options
.
alwaysRevealFirst
;
// hook up to diff editor for diff, disposal, and caret move
this
.
toUnbind
.
push
(
this
.
editor
.
addListener2
(
EventType
.
Disposed
,
()
=>
this
.
dispose
()
));
this
.
toUnbind
.
push
(
this
.
editor
.
addListener2
(
EventType
.
DiffUpdated
,
()
=>
this
.
onDiffUpdated
()
));
this
.
toUnbind
.
push
(
this
.
editor
.
onDidDispose
(
()
=>
this
.
dispose
()
));
this
.
toUnbind
.
push
(
this
.
editor
.
onDidUpdateDiff
(
()
=>
this
.
onDiffUpdated
()
));
if
(
this
.
options
.
followsCaret
)
{
this
.
toUnbind
.
push
(
this
.
editor
.
getModifiedEditor
().
addListener2
(
EventType
.
CursorPositionChanged
,
(
e
:
ICursorPositionChangedEvent
)
=>
{
this
.
toUnbind
.
push
(
this
.
editor
.
getModifiedEditor
().
onDidCursorPositionChange
(
(
e
:
ICursorPositionChangedEvent
)
=>
{
if
(
this
.
ignoreSelectionChange
)
{
return
;
}
...
...
@@ -75,7 +75,7 @@ export class DiffNavigator extends EventEmitter {
}));
}
if
(
this
.
options
.
alwaysRevealFirst
)
{
this
.
toUnbind
.
push
(
this
.
editor
.
getModifiedEditor
().
addListener2
(
EventType
.
ModelChanged
,
(
e
)
=>
{
this
.
toUnbind
.
push
(
this
.
editor
.
getModifiedEditor
().
onDidModelChange
(
(
e
)
=>
{
this
.
revealFirst
=
true
;
}));
}
...
...
src/vs/editor/contrib/find/browser/findWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -17,7 +17,7 @@ import {FindInput} from 'vs/base/browser/ui/findinput/findInput';
import
{
IMessage
as
InputBoxMessage
,
InputBox
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
EventType
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
,
IOverlayWidget
,
IOverlayWidgetPosition
,
OverlayWidgetPositionPreference
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
FIND_IDS
,
MATCHES_LIMIT
}
from
'
vs/editor/contrib/find/common/findModel
'
;
import
{
FindReplaceState
,
FindReplaceStateChangedEvent
}
from
'
vs/editor/contrib/find/common/findState
'
;
...
...
@@ -98,7 +98,7 @@ export class FindWidget extends Widget implements IOverlayWidget {
this
.
focusTracker
=
this
.
_register
(
dom
.
trackFocus
(
this
.
_findInput
.
inputBox
.
inputElement
));
this
.
focusTracker
.
addFocusListener
(()
=>
this
.
_reseedFindScope
());
this
.
_register
(
this
.
_codeEditor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
_register
(
this
.
_codeEditor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
readOnly
)
{
if
(
this
.
_codeEditor
.
getConfiguration
().
readOnly
)
{
// Hide replace part if editor becomes read only
...
...
@@ -107,7 +107,7 @@ export class FindWidget extends Widget implements IOverlayWidget {
this
.
_updateButtons
();
}
}));
this
.
_register
(
this
.
_codeEditor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
()
=>
{
this
.
_register
(
this
.
_codeEditor
.
onDidCursorSelectionChange
(
()
=>
{
if
(
this
.
_isVisible
)
{
this
.
_updateToggleSelectionFindButton
();
}
...
...
src/vs/editor/contrib/find/common/findController.ts
浏览文件 @
ceaa4ea2
...
...
@@ -60,7 +60,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
this
.
_model
=
null
;
this
.
_register
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
{
this
.
_register
(
this
.
_editor
.
onDidModelChange
(
()
=>
{
let
shouldRestartFind
=
(
this
.
_editor
.
getModel
()
&&
this
.
_state
.
isRevealed
);
this
.
disposeModel
();
...
...
@@ -523,7 +523,7 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd
this
.
updateSoon
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
_update
(),
300
));
this
.
lastWordUnderCursor
=
null
;
this
.
_register
(
editor
.
addListener2
(
editorCommon
.
EventType
.
CursorSelectionChanged
,
(
e
:
editorCommon
.
ICursorSelectionChangedEvent
)
=>
{
this
.
_register
(
editor
.
onDidCursorSelectionChange
(
(
e
:
editorCommon
.
ICursorSelectionChangedEvent
)
=>
{
if
(
e
.
selection
.
isEmpty
())
{
if
(
e
.
reason
===
editorCommon
.
CursorChangeReason
.
Explicit
)
{
if
(
!
this
.
lastWordUnderCursor
||
!
this
.
lastWordUnderCursor
.
containsPosition
(
e
.
selection
.
getStartPosition
()))
{
...
...
@@ -539,7 +539,7 @@ export class SelectionHighlighter extends Disposable implements editorCommon.IEd
this
.
_update
();
}
}));
this
.
_register
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
(
e
)
=>
{
this
.
_register
(
editor
.
onDidModelChange
(
(
e
)
=>
{
this
.
removeDecorations
();
}));
this
.
_register
(
CommonFindController
.
getFindController
(
editor
).
getState
().
addChangeListener
((
e
)
=>
{
...
...
src/vs/editor/contrib/find/common/findModel.ts
浏览文件 @
ceaa4ea2
...
...
@@ -57,7 +57,7 @@ export class FindModelBoundToEditorModel {
this
.
_updateDecorationsScheduler
=
new
RunOnceScheduler
(()
=>
this
.
research
(
false
),
100
);
this
.
_toDispose
.
push
(
this
.
_updateDecorationsScheduler
);
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidCursorPositionChange
(
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
{
if
(
e
.
reason
===
editorCommon
.
CursorChangeReason
.
Explicit
||
e
.
reason
===
editorCommon
.
CursorChangeReason
.
Undo
...
...
@@ -68,7 +68,7 @@ export class FindModelBoundToEditorModel {
}));
this
.
_ignoreModelContentChanged
=
false
;
this
.
_toDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelContentChanged
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
{
this
.
_toDispose
.
push
(
this
.
_editor
.
onDidModelContentChange
(
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
{
if
(
this
.
_ignoreModelContentChanged
)
{
return
;
}
...
...
src/vs/editor/contrib/folding/browser/folding.ts
浏览文件 @
ceaa4ea2
...
...
@@ -159,8 +159,8 @@ export class FoldingController implements editorCommon.IEditorContribution {
this
.
decorations
=
[];
this
.
computeToken
=
0
;
this
.
globalToDispose
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
onModelChanged
()));
this
.
globalToDispose
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
{
this
.
globalToDispose
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
this
.
onModelChanged
()));
this
.
globalToDispose
.
push
(
this
.
editor
.
onDidConfigurationChange
(
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
{
let
oldIsEnabled
=
this
.
_isEnabled
;
this
.
_isEnabled
=
this
.
editor
.
getConfiguration
().
contribInfo
.
folding
;
if
(
oldIsEnabled
!==
this
.
_isEnabled
)
{
...
...
@@ -311,7 +311,7 @@ export class FoldingController implements editorCommon.IEditorContribution {
this
.
localToDispose
.
push
(
this
.
contentChangedScheduler
);
this
.
localToDispose
.
push
(
this
.
cursorChangedScheduler
);
this
.
localToDispose
.
push
(
this
.
editor
.
addListener2
(
'
change
'
,
()
=>
{
this
.
localToDispose
.
push
(
this
.
editor
.
onDidModelContentChange
(
()
=>
{
this
.
contentChangedScheduler
.
schedule
();
}));
this
.
localToDispose
.
push
({
dispose
:
()
=>
{
...
...
@@ -323,9 +323,9 @@ export class FoldingController implements editorCommon.IEditorContribution {
this
.
decorations
=
[];
this
.
editor
.
setHiddenAreas
([]);
}});
this
.
localToDispose
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
e
=>
this
.
onEditorMouseDown
(
e
)));
this
.
localToDispose
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseUp
,
e
=>
this
.
onEditorMouseUp
(
e
)));
this
.
localToDispose
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
e
=>
{
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
.
onDidCursorPositionChange
(
e
=>
{
this
.
cursorChangedScheduler
.
schedule
();
}));
...
...
src/vs/editor/contrib/format/common/formatActions.ts
浏览文件 @
ceaa4ea2
...
...
@@ -36,9 +36,9 @@ class FormatOnType implements editorCommon.IEditorContribution {
this
.
callOnDispose
=
[];
this
.
callOnModel
=
[];
this
.
callOnDispose
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
()
=>
this
.
update
()));
this
.
callOnDispose
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
update
()));
this
.
callOnDispose
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
this
.
update
()));
this
.
callOnDispose
.
push
(
editor
.
onDidConfigurationChange
(
()
=>
this
.
update
()));
this
.
callOnDispose
.
push
(
editor
.
onDidModelChange
(
()
=>
this
.
update
()));
this
.
callOnDispose
.
push
(
editor
.
onDidModelModeChange
(
()
=>
this
.
update
()));
this
.
callOnDispose
.
push
(
OnTypeFormattingEditProviderRegistry
.
onDidChange
(
this
.
update
,
this
));
}
...
...
@@ -84,7 +84,7 @@ class FormatOnType implements editorCommon.IEditorContribution {
// install a listener that checks if edits happens before the
// position on which we format right now. Iff so, we won't
// apply the format edits
var
unbind
=
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelContentChanged
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
{
var
unbind
=
this
.
editor
.
onDidModelContentChange
(
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
{
if
(
e
.
changeType
===
editorCommon
.
EventType
.
ModelContentChangedFlush
)
{
// a model.setValue() was called
canceled
=
true
;
...
...
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
浏览文件 @
ceaa4ea2
...
...
@@ -222,15 +222,19 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
this
.
editor
=
editor
;
this
.
throttler
=
new
Throttler
();
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseDown
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseUp
,
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseUp
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseMove
,
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseMove
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
KeyDown
,
(
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyDown
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
KeyUp
,
(
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyUp
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
this
.
resetHandler
()));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
'
change
'
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
this
.
resetHandler
()));
this
.
toUnhook
.
push
(
this
.
editor
.
addListener2
(
'
scroll
'
,
()
=>
this
.
resetHandler
()));
this
.
toUnhook
.
push
(
this
.
editor
.
onMouseDown
((
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseDown
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
onMouseUp
((
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseUp
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
onMouseMove
((
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseMove
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
onKeyDown
((
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyDown
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
onKeyUp
((
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyUp
(
e
)));
this
.
toUnhook
.
push
(
this
.
editor
.
onDidModelChange
((
e
)
=>
this
.
resetHandler
()));
this
.
toUnhook
.
push
(
this
.
editor
.
onDidModelContentChange
((
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
this
.
resetHandler
()));
this
.
toUnhook
.
push
(
this
.
editor
.
onDidScrollChange
((
e
)
=>
{
if
(
e
.
scrollTopChanged
||
e
.
scrollLeftChanged
)
{
this
.
resetHandler
();
}
}));
}
private
onEditorMouseMove
(
mouseEvent
:
IEditorMouseEvent
,
withKey
?:
IKeyboardEvent
):
void
{
...
...
src/vs/editor/contrib/gotoError/browser/gotoError.ts
浏览文件 @
ceaa4ea2
...
...
@@ -52,8 +52,8 @@ class MarkerModel {
this
.
setMarkers
(
markers
);
// listen on editor
this
.
_toUnbind
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
Disposed
,
()
=>
this
.
dispose
()));
this
.
_toUnbind
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
()
=>
{
this
.
_toUnbind
.
push
(
this
.
_editor
.
onDidDispose
(
()
=>
this
.
dispose
()));
this
.
_toUnbind
.
push
(
this
.
_editor
.
onDidCursorPositionChange
(
()
=>
{
if
(
!
this
.
_ignoreSelectionChange
)
{
this
.
_nextIdx
=
-
1
;
}
...
...
@@ -437,7 +437,7 @@ class MarkerController implements editorCommon.IEditorContribution {
this
.
_callOnClose
.
push
(
this
.
_model
);
this
.
_callOnClose
.
push
(
this
.
_zone
);
this
.
_callOnClose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
{
this
.
_callOnClose
.
push
(
this
.
_editor
.
onDidModelChange
(
()
=>
{
this
.
_cleanUp
();
}));
...
...
src/vs/editor/contrib/hover/browser/hover.ts
浏览文件 @
ceaa4ea2
...
...
@@ -46,13 +46,17 @@ class ModesHoverController implements editorCommon.IEditorContribution {
this
.
_toUnhook
=
[];
if
(
editor
.
getConfiguration
().
contribInfo
.
hover
)
{
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
(
e
:
IEditorMouseEvent
)
=>
this
.
_onEditorMouseDown
(
e
)));
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
MouseMove
,
(
e
:
IEditorMouseEvent
)
=>
this
.
_onEditorMouseMove
(
e
)));
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
MouseLeave
,
(
e
:
IEditorMouseEvent
)
=>
this
.
_hideWidgets
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
KeyDown
,
(
e
:
IKeyboardEvent
)
=>
this
.
_onKeyDown
(
e
)));
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
_hideWidgets
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelDecorationsChanged
,
()
=>
this
.
_onModelDecorationsChanged
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
addListener2
(
'
scroll
'
,
()
=>
this
.
_hideWidgets
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onMouseDown
((
e
:
IEditorMouseEvent
)
=>
this
.
_onEditorMouseDown
(
e
)));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onMouseMove
((
e
:
IEditorMouseEvent
)
=>
this
.
_onEditorMouseMove
(
e
)));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onMouseLeave
((
e
:
IEditorMouseEvent
)
=>
this
.
_hideWidgets
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onKeyDown
((
e
:
IKeyboardEvent
)
=>
this
.
_onKeyDown
(
e
)));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onDidModelChange
(()
=>
this
.
_hideWidgets
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onDidModelDecorationsChange
(()
=>
this
.
_onModelDecorationsChanged
()));
this
.
_toUnhook
.
push
(
this
.
_editor
.
onDidScrollChange
((
e
)
=>
{
if
(
e
.
scrollTopChanged
||
e
.
scrollLeftChanged
)
{
this
.
_hideWidgets
();
}
}));
this
.
_contentWidget
=
new
ModesContentHoverWidget
(
editor
,
openerService
);
this
.
_glyphWidget
=
new
ModesGlyphHoverWidget
(
editor
);
...
...
src/vs/editor/contrib/hover/browser/hoverWidgets.ts
浏览文件 @
ceaa4ea2
...
...
@@ -8,7 +8,7 @@ import {CommonKeybindings} from 'vs/base/common/keyCodes';
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
StyleMutator
}
from
'
vs/base/browser/styleMutator
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IEditorPosition
,
IPosition
,
EventType
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorPosition
,
IPosition
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
*
as
editorBrowser
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
...
...
@@ -45,7 +45,7 @@ export class ContentHoverWidget extends Widget implements editorBrowser.IContent
});
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
this
.
_register
(
this
.
_editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
_register
(
this
.
_editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
}
...
...
@@ -144,7 +144,7 @@ export class GlyphHoverWidget extends Widget implements editorBrowser.IOverlayWi
this
.
_showAtLineNumber
=
-
1
;
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
this
.
_register
(
this
.
_editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
_register
(
this
.
_editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
_editor
.
applyFontInfo
(
this
.
_domNode
);
}
...
...
src/vs/editor/contrib/iPadShowKeyboard/browser/iPadShowKeyboard.ts
浏览文件 @
ceaa4ea2
...
...
@@ -9,7 +9,7 @@ import 'vs/css!./iPadShowKeyboard';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
browser
from
'
vs/base/browser/browser
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
EventType
,
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
,
IOverlayWidget
,
IOverlayWidgetPosition
,
OverlayWidgetPositionPreference
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
...
...
@@ -25,7 +25,7 @@ export class IPadShowKeyboard implements IEditorContribution {
this
.
editor
=
editor
;
this
.
toDispose
=
[];
if
(
browser
.
isIPad
)
{
this
.
toDispose
.
push
(
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
editor
.
onDidConfigurationChange
(
()
=>
this
.
update
()));
this
.
update
();
}
}
...
...
src/vs/editor/contrib/links/browser/links.ts
浏览文件 @
ceaa4ea2
...
...
@@ -23,9 +23,10 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
{
CommonEditorRegistry
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ILink
,
LinkProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IEditorMouseEvent
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditorMouseEvent
,
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
getLinks
}
from
'
vs/editor/contrib/links/common/links
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
class
LinkOccurence
{
...
...
@@ -84,7 +85,13 @@ class Link {
}
}
class
LinkDetector
{
class
LinkDetector
implements
editorCommon
.
IEditorContribution
{
public
static
ID
:
string
=
'
editor.linkDetector
'
;
public
static
get
(
editor
:
editorCommon
.
ICommonCodeEditor
):
LinkDetector
{
return
<
LinkDetector
>
editor
.
getContribution
(
LinkDetector
.
ID
);
}
static
RECOMPUTE_TIME
=
1000
;
// ms
static
TRIGGER_KEY_VALUE
=
platform
.
isMacintosh
?
KeyCode
.
Meta
:
KeyCode
.
Ctrl
;
static
TRIGGER_MODIFIER
=
platform
.
isMacintosh
?
'
metaKey
'
:
'
ctrlKey
'
;
...
...
@@ -92,7 +99,7 @@ class LinkDetector {
static
CLASS_NAME
=
'
detected-link
'
;
static
CLASS_NAME_ACTIVE
=
'
detected-link-active
'
;
private
editor
:
editorCommon
.
ICommon
CodeEditor
;
private
editor
:
I
CodeEditor
;
private
listenersToRemove
:
IDisposable
[];
private
timeoutPromise
:
TPromise
<
void
>
;
private
computePromise
:
TPromise
<
ILink
[]
>
;
...
...
@@ -104,23 +111,23 @@ class LinkDetector {
private
currentOccurences
:{
[
decorationId
:
string
]:
LinkOccurence
;
};
constructor
(
editor
:
editorCommon
.
ICommon
CodeEditor
,
editorService
:
IEditorService
,
messageService
:
IMessageService
,
editorWorkerService
:
IEditorWorkerService
editor
:
I
CodeEditor
,
@
IEditorService
editorService
:
IEditorService
,
@
IMessageService
messageService
:
IMessageService
,
@
IEditorWorkerService
editorWorkerService
:
IEditorWorkerService
)
{
this
.
editor
=
editor
;
this
.
editorService
=
editorService
;
this
.
messageService
=
messageService
;
this
.
editorWorkerService
=
editorWorkerService
;
this
.
listenersToRemove
=
[];
this
.
listenersToRemove
.
push
(
editor
.
addListener2
(
'
change
'
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
this
.
onChange
()));
this
.
listenersToRemove
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
this
.
onModelChanged
()));
this
.
listenersToRemove
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
(
e
:
editorCommon
.
IModelModeChangedEvent
)
=>
this
.
onModelModeChanged
()));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseUp
,
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseUp
(
e
)));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
MouseMove
,
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseMove
(
e
)));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
KeyDown
,
(
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyDown
(
e
)));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
KeyUp
,
(
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyUp
(
e
)));
this
.
listenersToRemove
.
push
(
editor
.
onDidModelContentChange
(
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
this
.
onChange
()));
this
.
listenersToRemove
.
push
(
editor
.
onDidModelChange
((
e
)
=>
this
.
onModelChanged
()));
this
.
listenersToRemove
.
push
(
editor
.
onDidModelModeChange
((
e
)
=>
this
.
onModelModeChanged
()));
this
.
listenersToRemove
.
push
(
this
.
editor
.
onMouseUp
(
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseUp
(
e
)));
this
.
listenersToRemove
.
push
(
this
.
editor
.
onMouseMove
(
(
e
:
IEditorMouseEvent
)
=>
this
.
onEditorMouseMove
(
e
)));
this
.
listenersToRemove
.
push
(
this
.
editor
.
onKeyDown
(
(
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyDown
(
e
)));
this
.
listenersToRemove
.
push
(
this
.
editor
.
onKeyUp
(
(
e
:
IKeyboardEvent
)
=>
this
.
onEditorKeyUp
(
e
)));
this
.
timeoutPromise
=
null
;
this
.
computePromise
=
null
;
this
.
currentOccurences
=
{};
...
...
@@ -128,6 +135,10 @@ class LinkDetector {
this
.
beginCompute
();
}
public
getId
():
string
{
return
LinkDetector
.
ID
;
}
public
isComputing
():
boolean
{
return
TPromise
.
is
(
this
.
computePromise
);
}
...
...
@@ -406,40 +417,33 @@ class OpenLinkAction extends EditorAction {
static
ID
=
'
editor.action.openLink
'
;
private
_linkDetector
:
LinkDetector
;
constructor
(
descriptor
:
editorCommon
.
IEditorActionDescriptorData
,
editor
:
editorCommon
.
ICommonCodeEditor
,
@
IEditorService
editorService
:
IEditorService
,
@
IMessageService
messageService
:
IMessageService
,
@
IEditorWorkerService
editorWorkerService
:
IEditorWorkerService
editor
:
editorCommon
.
ICommonCodeEditor
)
{
super
(
descriptor
,
editor
,
Behaviour
.
WidgetFocus
|
Behaviour
.
UpdateOnCursorPositionChange
);
this
.
_linkDetector
=
new
LinkDetector
(
editor
,
editorService
,
messageService
,
editorWorkerService
);
}
public
dispose
():
void
{
this
.
_linkDetector
.
dispose
();
super
.
dispose
();
}
public
getEnablementState
():
boolean
{
if
(
this
.
_linkDetector
.
isComputing
())
{
if
(
LinkDetector
.
get
(
this
.
editor
)
.
isComputing
())
{
// optimistic enablement while state is being computed
return
true
;
}
return
!!
this
.
_linkDetector
.
getLinkOccurence
(
this
.
editor
.
getPosition
());
return
!!
LinkDetector
.
get
(
this
.
editor
)
.
getLinkOccurence
(
this
.
editor
.
getPosition
());
}
public
run
():
TPromise
<
any
>
{
var
link
=
this
.
_linkDetector
.
getLinkOccurence
(
this
.
editor
.
getPosition
());
var
link
=
LinkDetector
.
get
(
this
.
editor
)
.
getLinkOccurence
(
this
.
editor
.
getPosition
());
if
(
link
)
{
this
.
_linkDetector
.
openLinkOccurence
(
link
,
false
);
LinkDetector
.
get
(
this
.
editor
)
.
openLinkOccurence
(
link
,
false
);
}
return
TPromise
.
as
(
null
);
}
}
CommonEditorRegistry
.
registerEditorAction
(
new
EditorActionDescriptor
(
OpenLinkAction
,
OpenLinkAction
.
ID
,
nls
.
localize
(
'
label
'
,
"
Open Link
"
),
void
0
,
'
Open Link
'
));
EditorBrowserRegistry
.
registerEditorContribution
(
LinkDetector
);
src/vs/editor/contrib/outlineMarker/browser/outlineMarker.ts
浏览文件 @
ceaa4ea2
...
...
@@ -129,9 +129,9 @@ export class OutlineMarkerContribution implements editorCommon.IEditorContributi
this
.
_markers
=
[];
this
.
_currentOutlinePromise
=
null
;
this
.
_globalToDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
onChange
(
true
)));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
this
.
onChange
(
false
)));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ConfigurationChanged
,
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
{
this
.
_globalToDispose
.
push
(
this
.
_editor
.
onDidModelChange
(
()
=>
this
.
onChange
(
true
)));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
onDidModelModeChange
(
()
=>
this
.
onChange
(
false
)));
this
.
_globalToDispose
.
push
(
this
.
_editor
.
onDidConfigurationChange
(
(
e
:
editorCommon
.
IConfigurationChangedEvent
)
=>
{
let
oldIsEnabled
=
this
.
_isEnabled
;
this
.
_isEnabled
=
this
.
_editor
.
getConfiguration
().
contribInfo
.
outlineMarkers
;
if
(
oldIsEnabled
!==
this
.
_isEnabled
)
{
...
...
@@ -193,7 +193,7 @@ export class OutlineMarkerContribution implements editorCommon.IEditorContributi
});
},
250
);
this
.
_localToDispose
.
push
(
scheduler
);
this
.
_localToDispose
.
push
(
this
.
_editor
.
addListener2
(
'
change
'
,
()
=>
{
this
.
_localToDispose
.
push
(
this
.
_editor
.
onDidModelContentChange
(
()
=>
{
// Synchronously move markers
this
.
_editor
.
changeViewZones
((
viewAccessor
)
=>
{
...
...
src/vs/editor/contrib/parameterHints/browser/parameterHintsModel.ts
浏览文件 @
ceaa4ea2
...
...
@@ -8,7 +8,7 @@ import {RunOnceScheduler} from 'vs/base/common/async';
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
IDisposable
,
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
EventType
,
ICommonCodeEditor
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
ICursorSelectionChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
SignatureHelpProviderRegistry
,
SignatureHelp
}
from
'
vs/editor/common/modes
'
;
import
{
provideSignatureHelp
}
from
'
../common/parameterHints
'
;
...
...
@@ -42,9 +42,9 @@ export class ParameterHintsModel extends Disposable {
this
.
active
=
false
;
this
.
_register
(
this
.
editor
.
addListener2
(
EventType
.
ModelChanged
,
e
=>
this
.
onModelChanged
()));
this
.
_register
(
this
.
editor
.
addListener2
(
EventType
.
ModelModeChanged
,
_
=>
this
.
onModelChanged
()));
this
.
_register
(
this
.
editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
e
=>
this
.
onCursorChange
(
e
)));
this
.
_register
(
this
.
editor
.
onDidModelChange
(
e
=>
this
.
onModelChanged
()));
this
.
_register
(
this
.
editor
.
onDidModelModeChange
(
_
=>
this
.
onModelChanged
()));
this
.
_register
(
this
.
editor
.
onDidCursorSelectionChange
(
e
=>
this
.
onCursorChange
(
e
)));
this
.
_register
(
SignatureHelpProviderRegistry
.
onDidChange
(
this
.
onModelChanged
,
this
));
this
.
onModelChanged
();
}
...
...
src/vs/editor/contrib/parameterHints/browser/parameterHintsWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -11,7 +11,7 @@ import {IDisposable, dispose} from 'vs/base/common/lifecycle';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Builder
,
$
}
from
'
vs/base/browser/builder
'
;
import
aria
=
require
(
'
vs/base/browser/ui/aria/aria
'
);
import
{
EventType
,
ICursorSelectionChangedEvent
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICursorSelectionChangedEvent
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
SignatureHelp
,
SignatureInformation
}
from
'
vs/editor/common/modes
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IHintEvent
,
ParameterHintsModel
}
from
'
./parameterHintsModel
'
;
...
...
@@ -100,14 +100,14 @@ export class ParameterHintsWidget implements IContentWidget {
this
.
editor
.
addContentWidget
(
this
);
this
.
hide
();
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
(
e
:
ICursorSelectionChangedEvent
)
=>
{
this
.
toDispose
.
push
(
this
.
editor
.
onDidCursorSelectionChange
(
(
e
:
ICursorSelectionChangedEvent
)
=>
{
if
(
this
.
isVisible
)
{
this
.
editor
.
layoutContentWidget
(
this
);
}
}));
this
.
editor
.
applyFontInfo
(
this
.
getDomNode
());
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
toDispose
.
push
(
this
.
editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
editor
.
applyFontInfo
(
this
.
getDomNode
());
}
...
...
src/vs/editor/contrib/quickFix/browser/quickFixModel.ts
浏览文件 @
ceaa4ea2
...
...
@@ -14,7 +14,7 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IMarker
,
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
EventType
,
ICursorPositionChangedEvent
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICursorPositionChangedEvent
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CodeActionProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
IQuickFix2
,
getCodeActions
}
from
'
../common/quickFix
'
;
...
...
@@ -78,8 +78,8 @@ export class QuickFixModel extends EventEmitter {
this
.
autoSuggestDelay
=
300
;
}
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ModelChanged
,
()
=>
this
.
onModelChanged
()));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ModelModeChanged
,
()
=>
this
.
onModelChanged
()));
this
.
toDispose
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
this
.
onModelChanged
()));
this
.
toDispose
.
push
(
this
.
editor
.
onDidModelModeChange
(
()
=>
this
.
onModelChanged
()));
this
.
toDispose
.
push
(
CodeActionProviderRegistry
.
onDidChange
(
this
.
onModelChanged
,
this
));
}
...
...
@@ -98,7 +98,7 @@ export class QuickFixModel extends EventEmitter {
this
.
markerService
.
onMarkerChanged
(
this
.
onMarkerChanged
,
this
,
this
.
toLocalDispose
);
this
.
toLocalDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
CursorPositionChanged
,
(
e
:
ICursorPositionChangedEvent
)
=>
{
this
.
toLocalDispose
.
push
(
this
.
editor
.
onDidCursorPositionChange
(
(
e
:
ICursorPositionChangedEvent
)
=>
{
this
.
onCursorPositionChanged
();
}));
}
...
...
src/vs/editor/contrib/quickFix/browser/quickFixSelectionWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -16,7 +16,7 @@ import {IDataSource, IFocusEvent, IRenderer, ISelectionEvent, ITree, IAccessibil
import
{
DefaultController
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
EventType
,
ICursorSelectionChangedEvent
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICursorSelectionChangedEvent
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IQuickFix2
}
from
'
../common/quickFix
'
;
import
{
QuickFixModel
}
from
'
./quickFixModel
'
;
...
...
@@ -313,7 +313,7 @@ export class QuickFixSelectionWidget implements IContentWidget {
this
.
editor
.
addContentWidget
(
this
);
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
(
e
:
ICursorSelectionChangedEvent
)
=>
{
this
.
listenersToRemove
.
push
(
this
.
editor
.
onDidCursorSelectionChange
(
(
e
:
ICursorSelectionChangedEvent
)
=>
{
if
(
this
.
isActive
)
{
this
.
editor
.
layoutContentWidget
(
this
);
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesController.ts
浏览文件 @
ceaa4ea2
...
...
@@ -89,8 +89,8 @@ export class ReferencesController implements editorCommon.IEditorContribution {
this
.
_referenceSearchVisible
.
set
(
true
);
// close the widget on model/mode changes
this
.
_disposables
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelModeChanged
,
()
=>
{
this
.
closeWidget
();
}));
this
.
_disposables
.
push
(
this
.
_editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
{
this
.
_disposables
.
push
(
this
.
_editor
.
onDidModelModeChange
(
()
=>
{
this
.
closeWidget
();
}));
this
.
_disposables
.
push
(
this
.
_editor
.
onDidModelChange
(
()
=>
{
if
(
!
this
.
_ignoreModelChangeEvent
)
{
this
.
closeWidget
();
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -34,7 +34,7 @@ import {DefaultConfig} from 'vs/editor/common/config/defaultConfig';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
ICodeEditor
,
IMouseTarget
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
PeekViewWidget
,
IPeekViewService
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
FileReferences
,
OneReference
,
ReferencesModel
}
from
'
./referencesModel
'
;
...
...
@@ -52,7 +52,7 @@ class DecorationsManager implements IDisposable {
private
_callOnModelChange
:
IDisposable
[]
=
[];
constructor
(
private
editor
:
ICodeEditor
,
private
model
:
ReferencesModel
)
{
this
.
_callOnDispose
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
this
.
_onModelChanged
()));
this
.
_callOnDispose
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
this
.
_onModelChanged
()));
this
.
_onModelChanged
();
}
...
...
@@ -649,7 +649,7 @@ export class ReferenceWidget extends PeekViewWidget {
}));
// listen on editor
this
.
_disposeOnNewModel
.
push
(
this
.
_preview
.
addListener2
(
editorCommon
.
EventType
.
MouseDown
,
(
e
:
{
event
:
MouseEvent
;
target
:
IMouseTarget
;
}
)
=>
{
this
.
_disposeOnNewModel
.
push
(
this
.
_preview
.
onMouseDown
((
e
)
=>
{
if
(
e
.
event
.
detail
===
2
)
{
this
.
_onDidSelectReference
.
fire
({
element
:
this
.
_getFocusedReference
(),
...
...
src/vs/editor/contrib/rename/browser/renameInputField.ts
浏览文件 @
ceaa4ea2
...
...
@@ -11,7 +11,7 @@ import {canceled} from 'vs/base/common/errors';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
EventType
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
export
default
class
RenameInputField
implements
IContentWidget
,
IDisposable
{
...
...
@@ -116,8 +116,8 @@ export default class RenameInputField implements IContentWidget, IDisposable {
}
};
disposeOnDone
.
push
(
this
.
_editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
onCursorChanged
));
disposeOnDone
.
push
(
this
.
_editor
.
addListener2
(
EventType
.
EditorBlur
,
this
.
_currentCancelInput
));
disposeOnDone
.
push
(
this
.
_editor
.
onDidCursorSelectionChange
(
onCursorChanged
));
disposeOnDone
.
push
(
this
.
_editor
.
onDidEditorBlur
(
this
.
_currentCancelInput
));
this
.
_show
();
...
...
src/vs/editor/contrib/selectionClipboard/electron-browser/selectionClipboard.ts
浏览文件 @
ceaa4ea2
...
...
@@ -9,7 +9,7 @@ import {clipboard} from 'electron';
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
ICodeEditor
,
IEditorMouseEvent
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
EndOfLinePreference
,
EventType
,
IEditorContribution
,
ICursorSelectionChangedEvent
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EndOfLinePreference
,
IEditorContribution
,
ICursorSelectionChangedEvent
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
...
...
@@ -25,13 +25,13 @@ class SelectionClipboard extends Disposable implements IEditorContribution {
if
(
platform
.
isLinux
)
{
var
isEnabled
=
editor
.
getConfiguration
().
contribInfo
.
selectionClipboard
;
this
.
_register
(
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
_register
(
editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
contribInfo
)
{
isEnabled
=
editor
.
getConfiguration
().
contribInfo
.
selectionClipboard
;
}
}));
this
.
_register
(
editor
.
addListener2
(
EventType
.
MouseDown
,
(
e
:
IEditorMouseEvent
)
=>
{
this
.
_register
(
editor
.
onMouseDown
(
(
e
:
IEditorMouseEvent
)
=>
{
if
(
!
isEnabled
)
{
return
;
}
...
...
@@ -81,7 +81,7 @@ class SelectionClipboard extends Disposable implements IEditorContribution {
clipboard
.
writeText
(
textToCopy
,
'
selection
'
);
},
100
));
this
.
_register
(
editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
(
e
:
ICursorSelectionChangedEvent
)
=>
{
this
.
_register
(
editor
.
onDidCursorSelectionChange
(
(
e
:
ICursorSelectionChangedEvent
)
=>
{
if
(
!
isEnabled
)
{
return
;
}
...
...
src/vs/editor/contrib/smartSelect/common/smartSelect.ts
浏览文件 @
ceaa4ea2
...
...
@@ -12,7 +12,7 @@ import {IInstantiationService} from 'vs/platform/instantiation/common/instantiat
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
EditorAction
}
from
'
vs/editor/common/editorAction
'
;
import
{
Behaviour
}
from
'
vs/editor/common/editorActionEnablement
'
;
import
{
EventType
,
ICommonCodeEditor
,
ICursorPositionChangedEvent
,
IEditorActionDescriptorData
,
IEditorRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
ICursorPositionChangedEvent
,
IEditorActionDescriptorData
,
IEditorRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
TokenSelectionSupport
,
ILogicalSelectionEntry
}
from
'
./tokenSelectionSupport
'
;
...
...
@@ -98,7 +98,7 @@ class SmartSelect extends EditorAction {
state
=
editorState
;
// listen to caret move and forget about state
var
unhook
=
this
.
editor
.
addListener2
(
EventType
.
CursorPositionChanged
,
(
e
:
ICursorPositionChangedEvent
)
=>
{
var
unhook
=
this
.
editor
.
onDidCursorPositionChange
(
(
e
:
ICursorPositionChangedEvent
)
=>
{
if
(
ignoreSelection
)
{
return
;
}
...
...
src/vs/editor/contrib/snippet/common/snippet.ts
浏览文件 @
ceaa4ea2
...
...
@@ -460,7 +460,7 @@ class InsertSnippetController {
});
this
.
listenersToRemove
=
[];
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelContentChanged
,
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
{
this
.
listenersToRemove
.
push
(
this
.
editor
.
onDidModelContentChange
(
(
e
:
editorCommon
.
IModelContentChangedEvent
)
=>
{
if
(
this
.
isFinished
)
{
return
;
}
...
...
@@ -502,7 +502,7 @@ class InsertSnippetController {
}
}));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
{
this
.
listenersToRemove
.
push
(
this
.
editor
.
onDidCursorPositionChange
(
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
{
if
(
this
.
isFinished
)
{
return
;
}
...
...
@@ -513,19 +513,19 @@ class InsertSnippetController {
}
}));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
()
=>
{
this
.
listenersToRemove
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
{
this
.
stopAll
();
}));
var
blurTimeout
=
-
1
;
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
EditorBlur
,
()
=>
{
this
.
listenersToRemove
.
push
(
this
.
editor
.
onDidEditorBlur
(
()
=>
{
// Blur if within 100ms we do not focus back
blurTimeout
=
setTimeout
(()
=>
{
this
.
stopAll
();
},
100
);
}));
this
.
listenersToRemove
.
push
(
this
.
editor
.
addListener2
(
editorCommon
.
EventType
.
EditorFocus
,
()
=>
{
this
.
listenersToRemove
.
push
(
this
.
editor
.
onDidEditorFocus
(
()
=>
{
// Cancel the blur timeout (if any)
if
(
blurTimeout
!==
-
1
)
{
clearTimeout
(
blurTimeout
);
...
...
src/vs/editor/contrib/suggest/browser/suggest.ts
浏览文件 @
ceaa4ea2
...
...
@@ -12,7 +12,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingContextKey
,
IKeybindingService
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
EditorAction
}
from
'
vs/editor/common/editorAction
'
;
import
{
EventType
,
ICommonCodeEditor
,
IEditorActionDescriptorData
,
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
IEditorActionDescriptorData
,
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
CommonEditorRegistry
,
ContextKey
,
EditorActionDescriptor
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ISuggestSupport
,
SuggestRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -50,9 +50,9 @@ export class SuggestController implements IEditorContribution {
this
.
toDispose
=
[];
this
.
toDispose
.
push
(
this
.
widget
.
onDidVisibilityChange
(
visible
=>
visible
?
this
.
suggestWidgetVisible
.
set
(
true
)
:
this
.
suggestWidgetVisible
.
reset
()));
this
.
toDispose
.
push
(
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
editor
.
addListener2
(
EventType
.
ModelChanged
,
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
editor
.
addListener2
(
EventType
.
ModelModeChanged
,
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
editor
.
onDidConfigurationChange
(
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
editor
.
onDidModelChange
(
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
editor
.
onDidModelModeChange
(
()
=>
this
.
update
()));
this
.
toDispose
.
push
(
SuggestRegistry
.
onDidChange
(
this
.
update
,
this
));
this
.
toDispose
.
push
(
this
.
model
.
onDidAccept
(
e
=>
getSnippetController
(
this
.
editor
).
run
(
e
.
snippet
,
e
.
overwriteBefore
,
e
.
overwriteAfter
)));
...
...
src/vs/editor/contrib/suggest/browser/suggestModel.ts
浏览文件 @
ceaa4ea2
...
...
@@ -9,7 +9,7 @@ import Event, { Emitter } from 'vs/base/common/event';
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
startsWith
}
from
'
vs/base/common/strings
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
EventType
,
ICommonCodeEditor
,
ICursorSelectionChangedEvent
,
IEditorPosition
,
CursorChangeReason
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICommonCodeEditor
,
ICursorSelectionChangedEvent
,
IEditorPosition
,
CursorChangeReason
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ISuggestSupport
,
ISuggestion
,
SuggestRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
CodeSnippet
}
from
'
vs/editor/contrib/snippet/common/snippet
'
;
import
{
ISuggestResult2
,
provideCompletionItems
}
from
'
../common/suggest
'
;
...
...
@@ -196,9 +196,9 @@ export class SuggestModel implements IDisposable {
this
.
context
=
null
;
this
.
toDispose
=
[];
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
()
=>
this
.
onEditorConfigurationChange
()));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
e
=>
this
.
onCursorChange
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ModelChanged
,
()
=>
this
.
cancel
()));
this
.
toDispose
.
push
(
this
.
editor
.
onDidConfigurationChange
(
()
=>
this
.
onEditorConfigurationChange
()));
this
.
toDispose
.
push
(
this
.
editor
.
onDidCursorSelectionChange
(
e
=>
this
.
onCursorChange
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
this
.
cancel
()));
this
.
toDispose
.
push
(
SuggestRegistry
.
onDidChange
(
this
.
onSuggestRegistryChange
,
this
));
this
.
onEditorConfigurationChange
();
}
...
...
src/vs/editor/contrib/suggest/browser/suggestWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -21,7 +21,7 @@ import {DomScrollableElement} from 'vs/base/browser/ui/scrollbar/scrollableEleme
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingContextKey
,
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybindingService
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
EventType
,
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IConfigurationChangedEvent
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ContentWidgetPositionPreference
,
ICodeEditor
,
IContentWidget
,
IContentWidgetPosition
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CONTEXT_SUGGESTION_SUPPORTS_ACCEPT_ON_KEY
}
from
'
../common/suggest
'
;
import
{
CompletionItem
,
CompletionModel
}
from
'
./completionModel
'
;
...
...
@@ -81,7 +81,7 @@ class Renderer implements IRenderer<CompletionItem, ISuggestionTemplateData> {
configureFont
();
data
.
disposables
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
data
.
disposables
.
push
(
this
.
editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
configureFont
();
}
...
...
@@ -231,7 +231,7 @@ class SuggestionDetails {
this
.
configureFont
();
this
.
disposables
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
disposables
.
push
(
this
.
editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
configureFont
();
}
...
...
@@ -369,10 +369,10 @@ export class SuggestWidget implements IContentWidget, IDisposable {
this
.
list
=
new
List
(
this
.
listElement
,
this
.
delegate
,
[
renderer
]);
this
.
toDispose
=
[
editor
.
addListener2
(
EventType
.
EditorTextBlur
,
()
=>
this
.
onEditorBlur
()),
editor
.
onDidEditorTextBlur
(
()
=>
this
.
onEditorBlur
()),
this
.
list
.
onSelectionChange
(
e
=>
this
.
onListSelection
(
e
)),
this
.
list
.
onFocusChange
(
e
=>
this
.
onListFocus
(
e
)),
this
.
editor
.
addListener2
(
EventType
.
CursorSelectionChanged
,
()
=>
this
.
onCursorSelectionChanged
()),
this
.
editor
.
onDidCursorSelectionChange
(
()
=>
this
.
onCursorSelectionChanged
()),
this
.
model
.
onDidTrigger
(
e
=>
this
.
onDidTrigger
(
e
)),
this
.
model
.
onDidSuggest
(
e
=>
this
.
onDidSuggest
(
e
)),
this
.
model
.
onDidCancel
(
e
=>
this
.
onDidCancel
(
e
))
...
...
src/vs/editor/contrib/wordHighlighter/common/wordHighlighter.ts
浏览文件 @
ceaa4ea2
...
...
@@ -63,14 +63,14 @@ class WordHighlighter {
this
.
editor
=
editor
;
this
.
model
=
this
.
editor
.
getModel
();
this
.
toUnhook
=
[];
this
.
toUnhook
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
CursorPositionChanged
,
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
{
this
.
toUnhook
.
push
(
editor
.
onDidCursorPositionChange
(
(
e
:
editorCommon
.
ICursorPositionChangedEvent
)
=>
{
this
.
_onPositionChanged
(
e
);
}));
this
.
toUnhook
.
push
(
editor
.
addListener2
(
editorCommon
.
EventType
.
ModelChanged
,
(
e
)
=>
{
this
.
toUnhook
.
push
(
editor
.
onDidModelChange
(
(
e
)
=>
{
this
.
_stopAll
();
this
.
model
=
this
.
editor
.
getModel
();
}));
this
.
toUnhook
.
push
(
editor
.
addListener2
(
'
change
'
,
(
e
)
=>
{
this
.
toUnhook
.
push
(
editor
.
onDidModelContentChange
(
(
e
)
=>
{
this
.
_stopAll
();
}));
...
...
src/vs/editor/contrib/zoneWidget/browser/zoneWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -10,7 +10,7 @@ import {Disposables} from 'vs/base/common/lifecycle';
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
*
as
dom
from
'
vs/base/browser/dom
'
;
import
{
Sash
,
Orientation
,
IHorizontalSashLayoutProvider
,
ISashEvent
}
from
'
vs/base/browser/ui/sash/sash
'
;
import
{
E
ventType
,
E
ditorLayoutInfo
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
EditorLayoutInfo
,
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
ICodeEditor
,
IOverlayWidget
,
IOverlayWidgetPosition
,
IViewZone
,
IViewZoneChangeAccessor
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -111,7 +111,7 @@ export abstract class ZoneWidget implements IHorizontalSashLayoutProvider {
this
.
domNode
.
setAttribute
(
'
role
'
,
'
presentation
'
);
}
this
.
_disposables
.
add
(
this
.
editor
.
addListener2
(
EventType
.
EditorLayout
,
(
info
:
EditorLayoutInfo
)
=>
{
this
.
_disposables
.
add
(
this
.
editor
.
onDidLayoutChange
(
(
info
:
EditorLayoutInfo
)
=>
{
var
width
=
this
.
_getWidth
(
info
);
this
.
domNode
.
style
.
width
=
width
+
'
px
'
;
this
.
_onWidth
(
width
);
...
...
src/vs/platform/editor/common/editor.ts
浏览文件 @
ceaa4ea2
...
...
@@ -77,6 +77,10 @@ export interface IResourceInput {
};
}
export
interface
IEditorControl
{
}
export
interface
IEditor
{
/**
...
...
@@ -102,7 +106,7 @@ export interface IEditor {
/**
* Returns the underlying control of this editor.
*/
getControl
():
IE
ventEmitter
;
getControl
():
IE
ditorControl
;
/**
* Asks the underlying control to focus.
...
...
src/vs/platform/jsonschemas/common/jsonContributionRegistry.ts
浏览文件 @
ceaa4ea2
...
...
@@ -7,7 +7,7 @@
import
nls
=
require
(
'
vs/nls
'
);
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
platform
=
require
(
'
vs/platform/platform
'
);
import
{
IEventEmitter
,
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
EventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
export
const
Extensions
=
{
...
...
@@ -52,7 +52,7 @@ function normalizeId(id: string) {
class
JSONContributionRegistry
implements
IJSONContributionRegistry
{
private
schemasById
:
{
[
id
:
string
]:
IJSONSchema
};
private
eventEmitter
:
I
EventEmitter
;
private
eventEmitter
:
EventEmitter
;
constructor
()
{
this
.
schemasById
=
{};
...
...
src/vs/workbench/api/node/mainThreadEditors.ts
浏览文件 @
ceaa4ea2
...
...
@@ -127,7 +127,7 @@ export class MainThreadTextEditor {
if
(
this
.
_codeEditor
)
{
// Catch early the case that this code editor gets a different model set and disassociate from this model
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
ModelChanged
,
()
=>
{
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
onDidModelChange
(
()
=>
{
this
.
setCodeEditor
(
null
);
}));
...
...
@@ -135,17 +135,17 @@ export class MainThreadTextEditor {
this
.
_lastSelection
=
this
.
_codeEditor
.
getSelections
();
this
.
_onSelectionChanged
.
fire
(
this
.
_lastSelection
);
};
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
CursorSelectionChanged
,
forwardSelection
));
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
onDidCursorSelectionChange
(
forwardSelection
));
if
(
!
Selection
.
selectionsArrEqual
(
this
.
_lastSelection
,
this
.
_codeEditor
.
getSelections
()))
{
forwardSelection
();
}
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
EditorFocus
,
()
=>
{
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
onDidEditorFocus
(
()
=>
{
this
.
_focusTracker
.
onGainedFocus
();
}));
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
EditorBlur
,
()
=>
{
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
onDidEditorBlur
(
()
=>
{
this
.
_focusTracker
.
onLostFocus
();
}));
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
ConfigurationChanged
,
()
=>
{
this
.
_codeEditorListeners
.
push
(
this
.
_codeEditor
.
onDidConfigurationChange
(
()
=>
{
this
.
_setConfiguration
(
this
.
_readConfiguration
(
this
.
_model
,
this
.
_codeEditor
));
}));
this
.
_setConfiguration
(
this
.
_readConfiguration
(
this
.
_model
,
this
.
_codeEditor
));
...
...
@@ -407,7 +407,7 @@ export class MainThreadEditorsTracker {
}
private
_onCodeEditorAdd
(
codeEditor
:
EditorCommon
.
ICommonCodeEditor
):
void
{
this
.
_editorModelChangeListeners
[
codeEditor
.
getId
()]
=
codeEditor
.
addListener2
(
EditorCommon
.
EventType
.
ModelChanged
,
_
=>
this
.
_updateMapping
.
schedule
());
this
.
_editorModelChangeListeners
[
codeEditor
.
getId
()]
=
codeEditor
.
onDidModelChange
(
_
=>
this
.
_updateMapping
.
schedule
());
this
.
_updateMapping
.
schedule
();
}
...
...
src/vs/workbench/browser/composite.ts
浏览文件 @
ceaa4ea2
...
...
@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
Dimension
,
Builder
}
from
'
vs/base/browser/builder
'
;
import
{
IAction
,
IActionRunner
,
ActionRunner
}
from
'
vs/base/common/actions
'
;
import
{
IActionItem
}
from
'
vs/base/browser/ui/actionbar/actionbar
'
;
...
...
@@ -13,6 +12,7 @@ import {CompositeEvent} from 'vs/workbench/common/events';
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
AsyncDescriptor
}
from
'
vs/platform/instantiation/common/descriptors
'
;
import
{
IComposite
}
from
'
vs/workbench/common/composite
'
;
import
{
IEditorControl
}
from
'
vs/platform/editor/common/editor
'
;
/**
* Internal composite events to communicate with composite container.
...
...
@@ -187,7 +187,7 @@ export abstract class Composite extends WorkbenchComponent implements IComposite
/**
* Returns the underlying composite control or null if it is not accessible.
*/
public
getControl
():
IE
ventEmitter
{
public
getControl
():
IE
ditorControl
{
return
null
;
}
}
...
...
src/vs/workbench/browser/parts/editor/textEditor.ts
浏览文件 @
ceaa4ea2
...
...
@@ -133,28 +133,28 @@ export abstract class BaseTextEditor extends BaseEditor {
this
.
editorControl
=
this
.
createEditorControl
(
parent
);
// Hook Listener for Selection changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
addListener2
(
EventType
.
CursorPositionChanged
,
(
event
:
ICursorPositionChangedEvent
)
=>
{
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidCursorPositionChange
(
(
event
:
ICursorPositionChangedEvent
)
=>
{
let
selection
=
this
.
editorControl
.
getSelection
();
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_SELECTION_CHANGED
,
new
TextEditorSelectionEvent
(
selection
,
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for mode changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
addListener2
(
EventType
.
ModelModeChanged
,
(
event
:
IModelModeChangedEvent
)
=>
{
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidModelModeChange
(
(
event
:
IModelModeChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_MODE_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for content changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
addListener2
(
EventType
.
ModelContentChanged
,
(
event
:
IModelContentChangedEvent
)
=>
{
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidModelContentChange
(
(
event
:
IModelContentChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONTENT_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for content options changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
addListener2
(
EventType
.
ModelOptionsChanged
,
(
event
:
IModelOptionsChangedEvent
)
=>
{
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidModelOptionsChange
(
(
event
:
IModelOptionsChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONTENT_OPTIONS_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
}));
// Hook Listener for options changes
this
.
toUnbind
.
push
(
this
.
editorControl
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
event
:
IConfigurationChangedEvent
)
=>
{
this
.
toUnbind
.
push
(
this
.
editorControl
.
onDidConfigurationChange
(
(
event
:
IConfigurationChangedEvent
)
=>
{
this
.
eventService
.
emit
(
WorkbenchEventType
.
TEXT_EDITOR_CONFIGURATION_CHANGED
,
new
EditorEvent
(
this
,
this
.
getId
(),
this
.
input
,
null
,
this
.
position
,
event
));
}));
...
...
src/vs/workbench/common/composite.ts
浏览文件 @
ceaa4ea2
...
...
@@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
IEventEmitter
}
from
'
vs/base/common/eventEmitter
'
;
import
{
IAction
,
IActionItem
}
from
'
vs/base/common/actions
'
;
import
{
IEditorControl
}
from
'
vs/platform/editor/common/editor
'
;
export
interface
IComposite
{
...
...
@@ -36,7 +36,7 @@ export interface IComposite {
/**
* Returns the underlying control of this composite.
*/
getControl
():
IE
ventEmitter
;
getControl
():
IE
ditorControl
;
/**
* Asks the underlying control to focus.
...
...
src/vs/workbench/parts/debug/browser/breakpointWidget.ts
浏览文件 @
ceaa4ea2
...
...
@@ -13,7 +13,6 @@ import lifecycle = require('vs/base/common/lifecycle');
import
dom
=
require
(
'
vs/base/browser/dom
'
);
import
{
InputBox
}
from
'
vs/base/browser/ui/inputbox/inputBox
'
;
import
{
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
editorcommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
editorbrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
{
ZoneWidget
}
from
'
vs/editor/contrib/zoneWidget/browser/zoneWidget
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -46,7 +45,7 @@ export class BreakpointWidget extends ZoneWidget {
this
.
breakpointWidgetVisible
=
keybindingService
.
createKey
(
CONTEXT_BREAKPOINT_WIDGET_VISIBLE
,
false
);
this
.
breakpointWidgetVisible
.
set
(
true
);
BreakpointWidget
.
INSTANCE
=
this
;
this
.
toDispose
.
push
(
editor
.
addListener2
(
editorcommon
.
EventType
.
ModelChanged
,
()
=>
this
.
dispose
()));
this
.
toDispose
.
push
(
editor
.
onDidModelChange
(
()
=>
this
.
dispose
()));
}
public
static
createInstance
(
editor
:
editorbrowser
.
ICodeEditor
,
lineNumber
:
number
,
instantiationService
:
IInstantiationService
):
void
{
...
...
src/vs/workbench/parts/debug/browser/debugEditorContribution.ts
浏览文件 @
ceaa4ea2
...
...
@@ -73,7 +73,7 @@ export class DebugEditorContribution implements debug.IDebugEditorContribution {
}
private
registerListeners
():
void
{
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
MouseDown
,
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
{
this
.
toDispose
.
push
(
this
.
editor
.
onMouseDown
(
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
{
if
(
e
.
target
.
type
!==
editorcommon
.
MouseTargetType
.
GUTTER_GLYPH_MARGIN
||
/* after last line */
e
.
target
.
detail
)
{
return
;
}
...
...
@@ -105,7 +105,7 @@ export class DebugEditorContribution implements debug.IDebugEditorContribution {
}
}));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
MouseMove
,
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
{
this
.
toDispose
.
push
(
this
.
editor
.
onMouseMove
(
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
{
var
showBreakpointHintAtLineNumber
=
-
1
;
if
(
e
.
target
.
type
===
editorcommon
.
MouseTargetType
.
GUTTER_GLYPH_MARGIN
&&
this
.
debugService
.
getConfigurationManager
().
canSetBreakpointsIn
(
this
.
editor
.
getModel
()))
{
if
(
!
e
.
target
.
detail
)
{
...
...
@@ -115,18 +115,18 @@ export class DebugEditorContribution implements debug.IDebugEditorContribution {
}
this
.
ensureBreakpointHintDecoration
(
showBreakpointHintAtLineNumber
);
}));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
MouseLeave
,
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
{
this
.
toDispose
.
push
(
this
.
editor
.
onMouseLeave
(
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
{
this
.
ensureBreakpointHintDecoration
(
-
1
);
}));
this
.
toDispose
.
push
(
this
.
debugService
.
onDidChangeState
(
state
=>
this
.
onDebugStateUpdate
(
state
)));
// hover listeners & hover widget
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
MouseDown
,
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
this
.
onEditorMouseDown
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
MouseMove
,
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
this
.
onEditorMouseMove
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
MouseLeave
,
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
this
.
hoverWidget
.
hide
()));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
KeyDown
,
(
e
:
keyboard
.
IKeyboardEvent
)
=>
this
.
onKeyDown
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
ModelChanged
,
()
=>
this
.
hideHoverWidget
()));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
'
scroll
'
,
()
=>
this
.
hideHoverWidget
));
this
.
toDispose
.
push
(
this
.
editor
.
onMouseDown
(
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
this
.
onEditorMouseDown
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
onMouseMove
(
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
this
.
onEditorMouseMove
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
onMouseLeave
(
(
e
:
editorbrowser
.
IEditorMouseEvent
)
=>
this
.
hoverWidget
.
hide
()));
this
.
toDispose
.
push
(
this
.
editor
.
onKeyDown
(
(
e
:
keyboard
.
IKeyboardEvent
)
=>
this
.
onKeyDown
(
e
)));
this
.
toDispose
.
push
(
this
.
editor
.
onDidModelChange
(
()
=>
this
.
hideHoverWidget
()));
this
.
toDispose
.
push
(
this
.
editor
.
onDidScrollChange
(
()
=>
this
.
hideHoverWidget
));
}
public
getId
():
string
{
...
...
src/vs/workbench/parts/debug/browser/debugHover.ts
浏览文件 @
ceaa4ea2
...
...
@@ -12,7 +12,7 @@ import * as nls from 'vs/nls';
import
{
ITree
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
Tree
}
from
'
vs/base/parts/tree/browser/treeImpl
'
;
import
{
DefaultController
,
ICancelableEvent
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
EventType
,
IConfigurationChangedEvent
,
IEditorPosition
,
IEditorRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IConfigurationChangedEvent
,
IEditorPosition
,
IEditorRange
}
from
'
vs/editor/common/editorCommon
'
;
import
editorbrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
debug
=
require
(
'
vs/workbench/parts/debug/common/debug
'
);
...
...
@@ -83,7 +83,7 @@ export class DebugHoverWidget implements editorbrowser.IContentWidget {
this
.
hide
();
}
}));
this
.
toDispose
.
push
(
this
.
editor
.
addListener2
(
EventType
.
ConfigurationChanged
,
(
e
:
IConfigurationChangedEvent
)
=>
{
this
.
toDispose
.
push
(
this
.
editor
.
onDidConfigurationChange
(
(
e
:
IConfigurationChangedEvent
)
=>
{
if
(
e
.
fontInfo
)
{
this
.
editor
.
applyFontInfo
(
this
.
domNode
);
}
...
...
src/vs/workbench/parts/git/browser/gitActions.contribution.ts
浏览文件 @
ceaa4ea2
...
...
@@ -255,8 +255,8 @@ export class StageRangesAction extends baseeditor.EditorInputAction {
this
.
editorService
=
editorService
;
this
.
gitService
=
gitService
;
this
.
editor
=
editor
.
getControl
();
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
CursorSelectionChanged
,
this
.
updateEnablement
.
bind
(
this
));
this
.
editor
.
addListener2
(
editorcommon
.
EventType
.
DiffUpdated
,
this
.
updateEnablement
.
bind
(
this
));
this
.
editor
.
onDidCursorSelectionChange
(()
=>
this
.
updateEnablement
(
));
this
.
editor
.
onDidUpdateDiff
(()
=>
this
.
updateEnablement
(
));
this
.
class
=
'
git-action stage-ranges
'
;
}
...
...
src/vs/workbench/parts/git/browser/gitEditorContributions.ts
浏览文件 @
ceaa4ea2
...
...
@@ -98,7 +98,7 @@ export class MergeDecorator implements common.IEditorContribution {
this
.
gitService
=
gitService
;
this
.
contextService
=
contextService
;
this
.
editor
=
editor
;
this
.
toUnbind
=
[
this
.
editor
.
addListener2
(
common
.
EventType
.
ModelChanged
,
()
=>
this
.
onModelChanged
())
];
this
.
toUnbind
=
[
this
.
editor
.
onDidModelChange
(
()
=>
this
.
onModelChanged
())
];
this
.
mergeDecorator
=
null
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录