Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
cf77b6ea
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
cf77b6ea
编写于
5月 17, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
grid - fold texteditor service into codeeditor service
上级
be8abde8
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
270 addition
and
261 deletion
+270
-261
src/vs/editor/browser/controller/coreCommands.ts
src/vs/editor/browser/controller/coreCommands.ts
+3
-19
src/vs/editor/browser/editorExtensions.ts
src/vs/editor/browser/editorExtensions.ts
+3
-25
src/vs/editor/browser/services/abstractCodeEditorService.ts
src/vs/editor/browser/services/abstractCodeEditorService.ts
+5
-0
src/vs/editor/browser/services/codeEditorService.ts
src/vs/editor/browser/services/codeEditorService.ts
+5
-0
src/vs/editor/browser/services/codeEditorServiceImpl.ts
src/vs/editor/browser/services/codeEditorServiceImpl.ts
+6
-1
src/vs/editor/browser/services/openerService.ts
src/vs/editor/browser/services/openerService.ts
+3
-3
src/vs/editor/browser/services/textEditorService.ts
src/vs/editor/browser/services/textEditorService.ts
+0
-29
src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts
...s/editor/contrib/goToDefinition/goToDefinitionCommands.ts
+6
-6
src/vs/editor/contrib/gotoError/gotoError.ts
src/vs/editor/contrib/gotoError/gotoError.ts
+5
-5
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
+3
-3
src/vs/editor/contrib/referenceSearch/referencesController.ts
...vs/editor/contrib/referenceSearch/referencesController.ts
+4
-4
src/vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch.ts
...lone/browser/referenceSearch/standaloneReferenceSearch.ts
+2
-2
src/vs/editor/standalone/browser/simpleServices.ts
src/vs/editor/standalone/browser/simpleServices.ts
+1
-83
src/vs/editor/standalone/browser/standaloneCodeServiceImpl.ts
...vs/editor/standalone/browser/standaloneCodeServiceImpl.ts
+101
-0
src/vs/editor/standalone/browser/standaloneEditor.ts
src/vs/editor/standalone/browser/standaloneEditor.ts
+2
-14
src/vs/editor/standalone/browser/standaloneServices.ts
src/vs/editor/standalone/browser/standaloneServices.ts
+2
-2
src/vs/editor/test/browser/editorTestServices.ts
src/vs/editor/test/browser/editorTestServices.ts
+8
-0
src/vs/editor/test/browser/services/decorationRenderOptions.test.ts
...tor/test/browser/services/decorationRenderOptions.test.ts
+23
-10
src/vs/editor/test/browser/services/openerService.test.ts
src/vs/editor/test/browser/services/openerService.test.ts
+27
-39
src/vs/workbench/electron-browser/shell.ts
src/vs/workbench/electron-browser/shell.ts
+6
-2
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+0
-7
src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts
...s/codeEditor/electron-browser/workbenchReferenceSearch.ts
+3
-3
src/vs/workbench/services/codeEditor/browser/codeEditorService.ts
...orkbench/services/codeEditor/browser/codeEditorService.ts
+49
-0
src/vs/workbench/services/editor/browser/nextEditorService.ts
...vs/workbench/services/editor/browser/nextEditorService.ts
+1
-2
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+2
-2
未找到文件。
src/vs/editor/browser/controller/coreCommands.ts
浏览文件 @
cf77b6ea
...
...
@@ -22,11 +22,10 @@ import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
*
as
types
from
'
vs/base/common/types
'
;
import
{
ICommandHandlerDescription
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
import
{
TypeOperations
}
from
'
vs/editor/common/controller/cursorTypeOperations
'
;
import
{
DeleteOperations
}
from
'
vs/editor/common/controller/cursorDeleteOperations
'
;
import
{
VerticalRevealType
}
from
'
vs/editor/common/view/viewEvents
'
;
import
{
ICodeEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
const
CORE_WEIGHT
=
KeybindingsRegistry
.
WEIGHT
.
editorCore
();
...
...
@@ -1620,21 +1619,6 @@ function findFocusedEditor(accessor: ServicesAccessor): ICodeEditor {
return
accessor
.
get
(
ICodeEditorService
).
getFocusedCodeEditor
();
}
function
getActiveEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
{
const
editorService
=
accessor
.
get
(
ITextEditorService
);
let
activeEditor
=
editorService
.
activeTextEditorControl
;
if
(
isCodeEditor
(
activeEditor
))
{
return
activeEditor
;
}
if
(
isDiffEditor
(
activeEditor
))
{
return
activeEditor
.
getModifiedEditor
();
}
return
null
;
}
function
registerCommand
(
command
:
Command
)
{
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
command
.
toCommandAndKeybindingRule
(
CORE_WEIGHT
));
}
...
...
@@ -1671,8 +1655,8 @@ class EditorOrNativeTextInputCommand extends Command {
return
;
}
// Redirecting to
last
active editor
let
activeEditor
=
getActiveEditor
(
accessor
);
// Redirecting to active editor
let
activeEditor
=
accessor
.
get
(
ICodeEditorService
).
getActiveCodeEditor
(
);
if
(
activeEditor
)
{
activeEditor
.
focus
();
return
this
.
_runEditorHandler
(
activeEditor
,
args
);
...
...
src/vs/editor/browser/editorExtensions.ts
浏览文件 @
cf77b6ea
...
...
@@ -16,10 +16,9 @@ import { Position } from 'vs/editor/common/core/position';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
MenuId
,
MenuRegistry
,
IMenuItem
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ICodeEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
export
type
ServicesAccessor
=
ServicesAccessor
;
...
...
@@ -85,21 +84,6 @@ export abstract class Command {
//#region EditorCommand
function
getActiveEditor
(
accessor
:
ServicesAccessor
):
ICodeEditor
{
const
editorService
=
accessor
.
get
(
ITextEditorService
);
let
activeEditor
=
editorService
.
activeTextEditorControl
;
if
(
isCodeEditor
(
activeEditor
))
{
return
activeEditor
;
}
if
(
isDiffEditor
(
activeEditor
))
{
return
activeEditor
.
getModifiedEditor
();
}
return
null
;
}
export
interface
IContributionCommandOptions
<
T
>
extends
ICommandOptions
{
handler
:
(
controller
:
T
)
=>
void
;
}
...
...
@@ -133,14 +117,8 @@ export abstract class EditorCommand extends Command {
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
|
TPromise
<
void
>
{
const
codeEditorService
=
accessor
.
get
(
ICodeEditorService
);
// Find the editor with text focus
let
editor
=
codeEditorService
.
getFocusedCodeEditor
();
if
(
!
editor
)
{
// Fallback to use the active editor
editor
=
getActiveEditor
(
accessor
);
}
// Find the editor with text focus or active
let
editor
=
codeEditorService
.
getFocusedCodeEditor
()
||
codeEditorService
.
getActiveCodeEditor
();
if
(
!
editor
)
{
// well, at least we tried...
return
;
...
...
src/vs/editor/browser/services/abstractCodeEditorService.ts
浏览文件 @
cf77b6ea
...
...
@@ -9,6 +9,8 @@ import { IDecorationRenderOptions } from 'vs/editor/common/editorCommon';
import
{
IModelDecorationOptions
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ICodeEditor
,
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
export
abstract
class
AbstractCodeEditorService
implements
ICodeEditorService
{
...
...
@@ -130,6 +132,9 @@ export abstract class AbstractCodeEditorService implements ICodeEditorService {
_removeWatcher
(
w
:
ModelTransientSettingWatcher
):
void
{
delete
this
.
_transientWatchers
[
w
.
uri
];
}
abstract
getActiveCodeEditor
():
ICodeEditor
;
abstract
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
;
}
export
class
ModelTransientSettingWatcher
{
...
...
src/vs/editor/browser/services/codeEditorService.ts
浏览文件 @
cf77b6ea
...
...
@@ -9,6 +9,8 @@ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'
import
{
IDecorationRenderOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IModelDecorationOptions
,
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
ICodeEditor
,
IDiffEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
export
const
ICodeEditorService
=
createDecorator
<
ICodeEditorService
>
(
'
codeEditorService
'
);
...
...
@@ -40,6 +42,9 @@ export interface ICodeEditorService {
setTransientModelProperty
(
model
:
ITextModel
,
key
:
string
,
value
:
any
):
void
;
getTransientModelProperty
(
model
:
ITextModel
,
key
:
string
):
any
;
getActiveCodeEditor
():
ICodeEditor
;
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
;
}
/**
...
...
src/vs/editor/browser/services/codeEditorServiceImpl.ts
浏览文件 @
cf77b6ea
...
...
@@ -12,8 +12,11 @@ import { IModelDecorationOptions, IModelDecorationOverviewRulerOptions, Overview
import
{
AbstractCodeEditorService
}
from
'
vs/editor/browser/services/abstractCodeEditorService
'
;
import
{
IDisposable
,
dispose
as
disposeAll
}
from
'
vs/base/common/lifecycle
'
;
import
{
IThemeService
,
ITheme
,
ThemeColor
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
export
class
CodeEditorServiceImpl
extends
AbstractCodeEditorService
{
export
abstract
class
CodeEditorServiceImpl
extends
AbstractCodeEditorService
{
private
_styleSheet
:
HTMLStyleElement
;
private
_decorationOptionProviders
:
{
[
key
:
string
]:
IModelDecorationOptionsProvider
};
...
...
@@ -65,6 +68,8 @@ export class CodeEditorServiceImpl extends AbstractCodeEditorService {
return
provider
.
getOptions
(
this
,
writable
);
}
abstract
getActiveCodeEditor
():
ICodeEditor
;
abstract
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
;
}
interface
IModelDecorationOptionsProvider
extends
IDisposable
{
...
...
src/vs/editor/browser/services/openerService.ts
浏览文件 @
cf77b6ea
...
...
@@ -9,7 +9,7 @@ import * as dom from 'vs/base/browser/dom';
import
{
parse
}
from
'
vs/base/common/marshalling
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
import
{
normalize
}
from
'
vs/base/common/paths
'
;
import
{
ICommandService
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
...
...
@@ -22,7 +22,7 @@ export class OpenerService implements IOpenerService {
_serviceBrand
:
any
;
constructor
(
@
I
TextEditorService
private
readonly
_editorService
:
IText
EditorService
,
@
I
CodeEditorService
private
readonly
_editorService
:
ICode
EditorService
,
@
ICommandService
private
readonly
_commandService
:
ICommandService
,
@
optional
(
ITelemetryService
)
private
_telemetryService
:
ITelemetryService
=
NullTelemetryService
)
{
...
...
@@ -81,7 +81,7 @@ export class OpenerService implements IOpenerService {
}
else
if
(
resource
.
scheme
===
Schemas
.
file
)
{
resource
=
resource
.
with
({
path
:
normalize
(
resource
.
path
)
});
// workaround for non-normalized paths (https://github.com/Microsoft/vscode/issues/12954)
}
promise
=
this
.
_editorService
.
open
Text
Editor
({
resource
,
options
:
{
selection
,
}
},
options
&&
options
.
openToSide
);
promise
=
this
.
_editorService
.
open
Code
Editor
({
resource
,
options
:
{
selection
,
}
},
options
&&
options
.
openToSide
);
}
return
promise
;
...
...
src/vs/editor/browser/services/textEditorService.ts
已删除
100644 → 0
浏览文件 @
be8abde8
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
createDecorator
,
ServiceIdentifier
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
export
const
ITextEditorService
=
createDecorator
<
ITextEditorService
>
(
'
textEditorService
'
);
export
interface
ITextEditorService
{
_serviceBrand
:
ServiceIdentifier
<
ITextEditorService
>
;
/**
* The currently active text editor or `null` if none.
*/
readonly
activeTextEditorControl
:
IEditor
;
/**
* Open a text editor.
*/
openTextEditor
(
editor
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
;
}
\ No newline at end of file
src/vs/editor/contrib/goToDefinition/goToDefinitionCommands.ts
浏览文件 @
cf77b6ea
...
...
@@ -10,7 +10,7 @@ import { alert } from 'vs/base/browser/ui/aria/aria';
import
{
KeyCode
,
KeyMod
,
KeyChord
}
from
'
vs/base/common/keyCodes
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
registerEditorAction
,
IActionOptions
,
ServicesAccessor
,
EditorAction
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
...
...
@@ -50,7 +50,7 @@ export class DefinitionAction extends EditorAction {
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
TPromise
<
void
>
{
const
notificationService
=
accessor
.
get
(
INotificationService
);
const
editorService
=
accessor
.
get
(
I
Text
EditorService
);
const
editorService
=
accessor
.
get
(
I
Code
EditorService
);
const
progressService
=
accessor
.
get
(
IProgressService
);
const
model
=
editor
.
getModel
();
...
...
@@ -125,7 +125,7 @@ export class DefinitionAction extends EditorAction {
return
model
.
references
.
length
>
1
&&
nls
.
localize
(
'
meta.title
'
,
"
– {0} definitions
"
,
model
.
references
.
length
);
}
private
_onResult
(
editorService
:
I
Text
EditorService
,
editor
:
ICodeEditor
,
model
:
ReferencesModel
)
{
private
_onResult
(
editorService
:
I
Code
EditorService
,
editor
:
ICodeEditor
,
model
:
ReferencesModel
)
{
const
msg
=
model
.
getAriaMessage
();
alert
(
msg
);
...
...
@@ -144,9 +144,9 @@ export class DefinitionAction extends EditorAction {
}
}
private
_openReference
(
editorService
:
I
Text
EditorService
,
reference
:
Location
,
sideBySide
:
boolean
):
TPromise
<
ICodeEditor
>
{
private
_openReference
(
editorService
:
I
Code
EditorService
,
reference
:
Location
,
sideBySide
:
boolean
):
TPromise
<
ICodeEditor
>
{
let
{
uri
,
range
}
=
reference
;
return
editorService
.
open
Text
Editor
({
return
editorService
.
open
Code
Editor
({
resource
:
uri
,
options
:
{
selection
:
Range
.
collapseToStart
(
range
),
...
...
@@ -156,7 +156,7 @@ export class DefinitionAction extends EditorAction {
},
sideBySide
);
}
private
_openInPeek
(
editorService
:
I
Text
EditorService
,
target
:
ICodeEditor
,
model
:
ReferencesModel
)
{
private
_openInPeek
(
editorService
:
I
Code
EditorService
,
target
:
ICodeEditor
,
model
:
ReferencesModel
)
{
let
controller
=
ReferencesController
.
get
(
target
);
if
(
controller
)
{
controller
.
toggleWidget
(
target
.
getSelection
(),
TPromise
.
as
(
model
),
{
...
...
src/vs/editor/contrib/gotoError/gotoError.ts
浏览文件 @
cf77b6ea
...
...
@@ -23,7 +23,7 @@ import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRe
import
{
MarkerNavigationWidget
}
from
'
./gotoErrorWidget
'
;
import
{
compare
}
from
'
vs/base/common/strings
'
;
import
{
binarySearch
}
from
'
vs/base/common/arrays
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
...
...
@@ -202,7 +202,7 @@ class MarkerController implements editorCommon.IEditorContribution {
@
IMarkerService
private
readonly
_markerService
:
IMarkerService
,
@
IContextKeyService
private
readonly
_contextKeyService
:
IContextKeyService
,
@
IThemeService
private
readonly
_themeService
:
IThemeService
,
@
I
TextEditorService
private
readonly
_editorService
:
IText
EditorService
@
I
CodeEditorService
private
readonly
_editorService
:
ICode
EditorService
)
{
this
.
_editor
=
editor
;
this
.
_widgetVisible
=
CONTEXT_MARKERS_NAVIGATION_VISIBLE
.
bindTo
(
this
.
_contextKeyService
);
...
...
@@ -239,7 +239,7 @@ class MarkerController implements editorCommon.IEditorContribution {
this
.
_disposeOnClose
.
push
(
this
.
_model
);
this
.
_disposeOnClose
.
push
(
this
.
_widget
);
this
.
_disposeOnClose
.
push
(
this
.
_widget
.
onDidSelectRelatedInformation
(
related
=>
{
this
.
_editorService
.
open
Text
Editor
({
this
.
_editorService
.
open
Code
Editor
({
resource
:
related
.
resource
,
options
:
{
pinned
:
true
,
revealIfOpened
:
true
,
selection
:
Range
.
lift
(
related
).
collapseToStart
()
}
}).
then
(
undefined
,
onUnexpectedError
);
...
...
@@ -305,7 +305,7 @@ class MarkerNavigationAction extends EditorAction {
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
TPromise
<
void
>
{
const
markerService
=
accessor
.
get
(
IMarkerService
);
const
editorService
=
accessor
.
get
(
I
Text
EditorService
);
const
editorService
=
accessor
.
get
(
I
Code
EditorService
);
const
controller
=
MarkerController
.
get
(
editor
);
if
(
!
controller
)
{
return
undefined
;
...
...
@@ -347,7 +347,7 @@ class MarkerNavigationAction extends EditorAction {
// for the next marker and re-start marker navigation in there
controller
.
closeMarkersNavigation
();
return
editorService
.
open
Text
Editor
({
return
editorService
.
open
Code
Editor
({
resource
:
newMarker
.
resource
,
options
:
{
pinned
:
false
,
revealIfOpened
:
true
,
revealInCenterIfOutsideViewport
:
true
,
selection
:
newMarker
}
}).
then
(
editor
=>
{
...
...
src/vs/editor/contrib/referenceSearch/referenceSearch.ts
浏览文件 @
cf77b6ea
...
...
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
import
{
CommandsRegistry
,
ICommandHandler
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IContextKeyService
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
...
...
@@ -103,7 +103,7 @@ let findReferencesCommand: ICommandHandler = (accessor: ServicesAccessor, resour
throw
new
Error
(
'
illegal argument, position
'
);
}
return
accessor
.
get
(
I
TextEditorService
).
openText
Editor
({
resource
}).
then
(
control
=>
{
return
accessor
.
get
(
I
CodeEditorService
).
openCode
Editor
({
resource
}).
then
(
control
=>
{
if
(
!
control
)
{
return
undefined
;
...
...
@@ -125,7 +125,7 @@ let showReferencesCommand: ICommandHandler = (accessor: ServicesAccessor, resour
throw
new
Error
(
'
illegal argument, uri expected
'
);
}
return
accessor
.
get
(
I
TextEditorService
).
openText
Editor
({
resource
}).
then
(
control
=>
{
return
accessor
.
get
(
I
CodeEditorService
).
openCode
Editor
({
resource
}).
then
(
control
=>
{
if
(
!
control
)
{
return
undefined
;
...
...
src/vs/editor/contrib/referenceSearch/referencesController.ts
浏览文件 @
cf77b6ea
...
...
@@ -8,7 +8,7 @@ import * as nls from 'vs/nls';
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
import
{
IInstantiationService
,
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextKey
,
IContextKeyService
,
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -54,7 +54,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
private
_defaultTreeKeyboardSupport
:
boolean
,
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
I
TextEditorService
private
readonly
_editorService
:
IText
EditorService
,
@
I
CodeEditorService
private
readonly
_editorService
:
ICode
EditorService
,
@
ITextModelService
private
readonly
_textModelResolverService
:
ITextModelService
,
@
INotificationService
private
readonly
_notificationService
:
INotificationService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
...
...
@@ -209,7 +209,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
this
.
_ignoreModelChangeEvent
=
true
;
const
range
=
Range
.
lift
(
ref
.
range
).
collapseToStart
();
return
this
.
_editorService
.
open
Text
Editor
({
return
this
.
_editorService
.
open
Code
Editor
({
resource
:
ref
.
uri
,
options
:
{
selection
:
range
}
}).
then
(
openedEditor
=>
{
...
...
@@ -238,7 +238,7 @@ export abstract class ReferencesController implements editorCommon.IEditorContri
public
openReference
(
ref
:
Location
,
sideBySide
:
boolean
):
void
{
const
{
uri
,
range
}
=
ref
;
this
.
_editorService
.
open
Text
Editor
({
this
.
_editorService
.
open
Code
Editor
({
resource
:
uri
,
options
:
{
selection
:
range
}
},
sideBySide
);
...
...
src/vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch.ts
浏览文件 @
cf77b6ea
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
import
{
IInstantiationService
,
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -23,7 +23,7 @@ export class StandaloneReferencesController extends ReferencesController {
public
constructor
(
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
I
TextEditorService
editorService
:
IText
EditorService
,
@
I
CodeEditorService
editorService
:
ICode
EditorService
,
@
ITextModelService
textModelResolverService
:
ITextModelService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
...
...
src/vs/editor/standalone/browser/simpleServices.ts
浏览文件 @
cf77b6ea
...
...
@@ -4,14 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IConfigurationService
,
IConfigurationChangeEvent
,
IConfigurationOverrides
,
IConfigurationData
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ISingleFolderWorkspaceIdentifier
,
IWorkspaceIdentifier
}
from
'
vs/platform/workspaces/common/workspaces
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
import
{
ICommandService
,
ICommand
,
ICommandEvent
,
ICommandHandler
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
AbstractKeybindingService
}
from
'
vs/platform/keybinding/common/abstractKeybindingService
'
;
import
{
USLayoutResolvedKeybinding
}
from
'
vs/platform/keybinding/common/usLayoutResolvedKeybinding
'
;
...
...
@@ -37,7 +34,7 @@ import { ITelemetryService, ITelemetryInfo } from 'vs/platform/telemetry/common/
import
{
ResolvedKeybinding
,
Keybinding
,
createKeybinding
,
SimpleKeybinding
}
from
'
vs/base/common/keyCodes
'
;
import
{
ResolvedKeybindingItem
}
from
'
vs/platform/keybinding/common/resolvedKeybindingItem
'
;
import
{
OS
}
from
'
vs/base/common/platform
'
;
import
{
IRange
,
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
INotificationService
,
INotification
,
INotificationHandle
,
NoOpNotification
,
IPromptChoice
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IConfirmation
,
IConfirmationResult
,
IDialogService
,
IDialogOptions
}
from
'
vs/platform/dialogs/common/dialogs
'
;
...
...
@@ -90,85 +87,6 @@ function withTypedEditor<T>(widget: editorCommon.IEditor, codeEditorCallback: (e
}
}
export
class
SimpleEditorService
implements
ITextEditorService
{
public
_serviceBrand
:
any
;
private
editor
:
editorCommon
.
IEditor
;
private
openEditorDelegate
:
IOpenEditorDelegate
;
constructor
()
{
this
.
openEditorDelegate
=
null
;
}
get
activeTextEditorControl
():
editorCommon
.
IEditor
{
return
null
;
}
public
setEditor
(
editor
:
editorCommon
.
IEditor
):
void
{
this
.
editor
=
editor
;
}
public
setOpenEditorDelegate
(
openEditorDelegate
:
IOpenEditorDelegate
):
void
{
this
.
openEditorDelegate
=
openEditorDelegate
;
}
public
openTextEditor
(
typedData
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
return
TPromise
.
as
(
withTypedEditor
(
this
.
editor
,
(
editor
)
=>
this
.
doOpenEditor
(
editor
,
typedData
),
(
diffEditor
)
=>
(
this
.
doOpenEditor
(
diffEditor
.
getOriginalEditor
(),
typedData
)
||
this
.
doOpenEditor
(
diffEditor
.
getModifiedEditor
(),
typedData
)
)
));
}
private
doOpenEditor
(
editor
:
ICodeEditor
,
data
:
IResourceInput
):
ICodeEditor
{
let
model
=
this
.
findModel
(
editor
,
data
);
if
(
!
model
)
{
if
(
data
.
resource
)
{
if
(
this
.
openEditorDelegate
)
{
this
.
openEditorDelegate
(
data
.
resource
.
toString
());
return
null
;
}
else
{
let
schema
=
data
.
resource
.
scheme
;
if
(
schema
===
Schemas
.
http
||
schema
===
Schemas
.
https
)
{
// This is a fully qualified http or https URL
dom
.
windowOpenNoOpener
(
data
.
resource
.
toString
());
return
editor
;
}
}
}
return
null
;
}
let
selection
=
<
IRange
>
data
.
options
.
selection
;
if
(
selection
)
{
if
(
typeof
selection
.
endLineNumber
===
'
number
'
&&
typeof
selection
.
endColumn
===
'
number
'
)
{
editor
.
setSelection
(
selection
);
editor
.
revealRangeInCenter
(
selection
,
editorCommon
.
ScrollType
.
Immediate
);
}
else
{
let
pos
=
{
lineNumber
:
selection
.
startLineNumber
,
column
:
selection
.
startColumn
};
editor
.
setPosition
(
pos
);
editor
.
revealPositionInCenter
(
pos
,
editorCommon
.
ScrollType
.
Immediate
);
}
}
return
editor
;
}
private
findModel
(
editor
:
ICodeEditor
,
data
:
IResourceInput
):
ITextModel
{
let
model
=
editor
.
getModel
();
if
(
model
.
uri
.
toString
()
!==
data
.
resource
.
toString
())
{
return
null
;
}
return
model
;
}
}
export
class
SimpleEditorModelResolverService
implements
ITextModelService
{
public
_serviceBrand
:
any
;
...
...
src/vs/editor/standalone/browser/standaloneCodeServiceImpl.ts
0 → 100644
浏览文件 @
cf77b6ea
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICodeEditor
,
IDiffEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
CodeEditorServiceImpl
}
from
'
vs/editor/browser/services/codeEditorServiceImpl
'
;
import
{
IEditor
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
windowOpenNoOpener
}
from
'
vs/base/browser/dom
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
export
class
StandaloneCodeEditorServiceImpl
extends
CodeEditorServiceImpl
{
private
editor
:
IEditor
;
addCodeEditor
(
editor
:
ICodeEditor
):
void
{
super
.
addCodeEditor
(
editor
);
if
(
!
this
.
editor
)
{
this
.
editor
=
editor
;
}
}
addDiffEditor
(
editor
:
IDiffEditor
):
void
{
super
.
addDiffEditor
(
editor
);
if
(
!
this
.
editor
)
{
this
.
editor
=
editor
;
}
}
public
getActiveCodeEditor
():
ICodeEditor
{
return
null
;
// not supported in the standalone case
}
public
openCodeEditor
(
typedData
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
return
TPromise
.
as
(
withTypedEditor
(
this
.
editor
,
(
editor
)
=>
this
.
doOpenEditor
(
editor
,
typedData
),
(
diffEditor
)
=>
(
this
.
doOpenEditor
(
diffEditor
.
getOriginalEditor
(),
typedData
)
||
this
.
doOpenEditor
(
diffEditor
.
getModifiedEditor
(),
typedData
)
)
));
}
private
doOpenEditor
(
editor
:
ICodeEditor
,
data
:
IResourceInput
):
ICodeEditor
{
let
model
=
this
.
findModel
(
editor
,
data
);
if
(
!
model
)
{
if
(
data
.
resource
)
{
let
schema
=
data
.
resource
.
scheme
;
if
(
schema
===
Schemas
.
http
||
schema
===
Schemas
.
https
)
{
// This is a fully qualified http or https URL
windowOpenNoOpener
(
data
.
resource
.
toString
());
return
editor
;
}
}
return
null
;
}
let
selection
=
<
IRange
>
data
.
options
.
selection
;
if
(
selection
)
{
if
(
typeof
selection
.
endLineNumber
===
'
number
'
&&
typeof
selection
.
endColumn
===
'
number
'
)
{
editor
.
setSelection
(
selection
);
editor
.
revealRangeInCenter
(
selection
,
ScrollType
.
Immediate
);
}
else
{
let
pos
=
{
lineNumber
:
selection
.
startLineNumber
,
column
:
selection
.
startColumn
};
editor
.
setPosition
(
pos
);
editor
.
revealPositionInCenter
(
pos
,
ScrollType
.
Immediate
);
}
}
return
editor
;
}
private
findModel
(
editor
:
ICodeEditor
,
data
:
IResourceInput
):
ITextModel
{
let
model
=
editor
.
getModel
();
if
(
model
.
uri
.
toString
()
!==
data
.
resource
.
toString
())
{
return
null
;
}
return
model
;
}
}
function
withTypedEditor
<
T
>
(
widget
:
IEditor
,
codeEditorCallback
:
(
editor
:
ICodeEditor
)
=>
T
,
diffEditorCallback
:
(
editor
:
IDiffEditor
)
=>
T
):
T
{
if
(
isCodeEditor
(
widget
))
{
// Single Editor
return
codeEditorCallback
(
<
ICodeEditor
>
widget
);
}
else
{
// Diff Editor
return
diffEditorCallback
(
<
IDiffEditor
>
widget
);
}
}
\ No newline at end of file
src/vs/editor/standalone/browser/standaloneEditor.ts
浏览文件 @
cf77b6ea
...
...
@@ -16,12 +16,11 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
OpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
Colorizer
,
IColorizerElementOptions
,
IColorizerOptions
}
from
'
vs/editor/standalone/browser/colorizer
'
;
import
{
SimpleEditor
Service
,
SimpleEditor
ModelResolverService
}
from
'
vs/editor/standalone/browser/simpleServices
'
;
import
{
SimpleEditorModelResolverService
}
from
'
vs/editor/standalone/browser/simpleServices
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
IWebWorkerOptions
,
MonacoWebWorker
,
createWebWorker
as
actualCreateWebWorker
}
from
'
vs/editor/common/services/webWorker
'
;
import
{
IMarkerData
,
IMarker
}
from
'
vs/platform/markers/common/markers
'
;
import
{
DiffNavigator
}
from
'
vs/editor/browser/widget/diffNavigator
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IContextViewService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
...
@@ -43,13 +42,6 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
function
withAllStandaloneServices
<
T
extends
editorCommon
.
IEditor
>
(
domElement
:
HTMLElement
,
override
:
IEditorOverrideServices
,
callback
:
(
services
:
DynamicStandaloneServices
)
=>
T
):
T
{
let
services
=
new
DynamicStandaloneServices
(
domElement
,
override
);
// The editorService is a lovely beast. It needs to point back to the code editor instance...
let
simpleEditorService
:
SimpleEditorService
=
null
;
if
(
!
services
.
has
(
ITextEditorService
))
{
simpleEditorService
=
new
SimpleEditorService
();
services
.
set
(
ITextEditorService
,
simpleEditorService
);
}
let
simpleEditorModelResolverService
:
SimpleEditorModelResolverService
=
null
;
if
(
!
services
.
has
(
ITextModelService
))
{
simpleEditorModelResolverService
=
new
SimpleEditorModelResolverService
();
...
...
@@ -57,15 +49,11 @@ function withAllStandaloneServices<T extends editorCommon.IEditor>(domElement: H
}
if
(
!
services
.
has
(
IOpenerService
))
{
services
.
set
(
IOpenerService
,
new
OpenerService
(
services
.
get
(
I
Text
EditorService
),
services
.
get
(
ICommandService
)));
services
.
set
(
IOpenerService
,
new
OpenerService
(
services
.
get
(
I
Code
EditorService
),
services
.
get
(
ICommandService
)));
}
let
result
=
callback
(
services
);
if
(
simpleEditorService
)
{
simpleEditorService
.
setEditor
(
result
);
}
if
(
simpleEditorModelResolverService
)
{
simpleEditorModelResolverService
.
setEditor
(
result
);
}
...
...
src/vs/editor/standalone/browser/standaloneServices.ts
浏览文件 @
cf77b6ea
...
...
@@ -29,7 +29,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
{
ModeServiceImpl
}
from
'
vs/editor/common/services/modeServiceImpl
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ModelServiceImpl
}
from
'
vs/editor/common/services/modelServiceImpl
'
;
import
{
CodeEditorServiceImpl
}
from
'
vs/editor/browser/services/codeEditor
ServiceImpl
'
;
import
{
StandaloneCodeEditorServiceImpl
}
from
'
vs/editor/standalone/browser/standaloneCode
ServiceImpl
'
;
import
{
SimpleConfigurationService
,
SimpleResourceConfigurationService
,
SimpleMenuService
,
SimpleProgressService
,
StandaloneCommandService
,
StandaloneKeybindingService
,
SimpleNotificationService
,
...
...
@@ -142,7 +142,7 @@ export module StaticServices {
export
const
standaloneThemeService
=
define
(
IStandaloneThemeService
,
()
=>
new
StandaloneThemeServiceImpl
());
export
const
codeEditorService
=
define
(
ICodeEditorService
,
(
o
)
=>
new
CodeEditorServiceImpl
(
standaloneThemeService
.
get
(
o
)));
export
const
codeEditorService
=
define
(
ICodeEditorService
,
(
o
)
=>
new
Standalone
CodeEditorServiceImpl
(
standaloneThemeService
.
get
(
o
)));
export
const
progressService
=
define
(
IProgressService
,
()
=>
new
SimpleProgressService
());
...
...
src/vs/editor/test/browser/editorTestServices.ts
浏览文件 @
cf77b6ea
...
...
@@ -11,8 +11,16 @@ import { ICommandService, ICommandEvent, CommandsRegistry } from 'vs/platform/co
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
export
class
TestCodeEditorService
extends
AbstractCodeEditorService
{
public
lastInput
:
IResourceInput
;
public
getActiveCodeEditor
():
ICodeEditor
{
return
null
;
}
public
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
this
.
lastInput
=
input
;
return
TPromise
.
as
(
null
);
}
public
registerDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
,
parentTypeKey
?:
string
):
void
{
}
public
removeDecorationType
(
key
:
string
):
void
{
}
public
resolveDecorationOptions
(
decorationTypeKey
:
string
,
writable
:
boolean
):
IModelDecorationOptions
{
return
null
;
}
...
...
src/vs/editor/test/browser/services/decorationRenderOptions.test.ts
浏览文件 @
cf77b6ea
...
...
@@ -10,9 +10,22 @@ import * as dom from 'vs/base/browser/dom';
import
{
CodeEditorServiceImpl
}
from
'
vs/editor/browser/services/codeEditorServiceImpl
'
;
import
{
IDecorationRenderOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
TestTheme
,
TestThemeService
}
from
'
vs/platform/theme/test/common/testThemeService
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
const
themeServiceMock
=
new
TestThemeService
();
export
class
TestCodeEditorServiceImpl
extends
CodeEditorServiceImpl
{
getActiveCodeEditor
():
ICodeEditor
{
return
null
;
}
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
return
TPromise
.
as
(
null
);
}
}
suite
(
'
Decoration Render Options
'
,
()
=>
{
let
options
:
IDecorationRenderOptions
=
{
gutterIconPath
:
URI
.
parse
(
'
https://github.com/Microsoft/vscode/blob/master/resources/linux/code.png
'
),
...
...
@@ -21,12 +34,12 @@ suite('Decoration Render Options', () => {
borderColor
:
'
yellow
'
};
test
(
'
register and resolve decoration type
'
,
()
=>
{
let
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
);
let
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
);
s
.
registerDecorationType
(
'
example
'
,
options
);
assert
.
notEqual
(
s
.
resolveDecorationOptions
(
'
example
'
,
false
),
undefined
);
});
test
(
'
remove decoration type
'
,
()
=>
{
let
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
);
let
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
);
s
.
registerDecorationType
(
'
example
'
,
options
);
assert
.
notEqual
(
s
.
resolveDecorationOptions
(
'
example
'
,
false
),
undefined
);
s
.
removeDecorationType
(
'
example
'
);
...
...
@@ -42,7 +55,7 @@ suite('Decoration Render Options', () => {
test
(
'
css properties
'
,
()
=>
{
let
styleSheet
=
dom
.
createStyleSheet
();
let
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
let
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
options
);
let
sheet
=
readStyleSheet
(
styleSheet
);
assert
(
...
...
@@ -64,7 +77,7 @@ suite('Decoration Render Options', () => {
let
styleSheet
=
dom
.
createStyleSheet
();
let
themeService
=
new
TestThemeService
(
new
TestTheme
(
colors
));
let
s
=
new
CodeEditorServiceImpl
(
themeService
,
styleSheet
);
let
s
=
new
Test
CodeEditorServiceImpl
(
themeService
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
options
);
let
sheet
=
readStyleSheet
(
styleSheet
);
assert
.
equal
(
sheet
,
'
.monaco-editor .ced-example-0 { background-color: rgb(255, 0, 0); border-color: transparent; box-sizing: border-box; }
'
);
...
...
@@ -103,7 +116,7 @@ suite('Decoration Render Options', () => {
let
styleSheet
=
dom
.
createStyleSheet
();
let
themeService
=
new
TestThemeService
(
new
TestTheme
(
colors
));
let
s
=
new
CodeEditorServiceImpl
(
themeService
,
styleSheet
);
let
s
=
new
Test
CodeEditorServiceImpl
(
themeService
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
options
);
let
sheet
=
readStyleSheet
(
styleSheet
);
let
expected
=
...
...
@@ -122,7 +135,7 @@ suite('Decoration Render Options', () => {
let
styleSheet
=
dom
.
createStyleSheet
();
// unix file path (used as string)
let
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
let
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
{
gutterIconPath
:
'
/Users/foo/bar.png
'
});
let
sheet
=
readStyleSheet
(
styleSheet
);
//.innerHTML || styleSheet.sheet.toString();
assert
(
...
...
@@ -131,7 +144,7 @@ suite('Decoration Render Options', () => {
);
// windows file path (used as string)
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
{
gutterIconPath
:
'
c:
\\
files
\\
miles
\\
more.png
'
});
sheet
=
readStyleSheet
(
styleSheet
);
// TODO@Alex test fails
...
...
@@ -141,7 +154,7 @@ suite('Decoration Render Options', () => {
// );
// URI, only minimal encoding
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
{
gutterIconPath
:
URI
.
parse
(
'
data:image/svg+xml;base64,PHN2ZyB4b+
'
)
});
sheet
=
readStyleSheet
(
styleSheet
);
assert
(
...
...
@@ -150,7 +163,7 @@ suite('Decoration Render Options', () => {
);
// single quote must always be escaped/encoded
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
{
gutterIconPath
:
'
/Users/foo/b
\'
ar.png
'
});
sheet
=
readStyleSheet
(
styleSheet
);
assert
(
...
...
@@ -158,7 +171,7 @@ suite('Decoration Render Options', () => {
||
sheet
.
indexOf
(
'
background: url("file:///Users/foo/b%27ar.png") center center no-repeat;
'
)
>
0
);
s
=
new
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
=
new
Test
CodeEditorServiceImpl
(
themeServiceMock
,
styleSheet
);
s
.
registerDecorationType
(
'
example
'
,
{
gutterIconPath
:
URI
.
parse
(
'
http://test/pa
\'
th
'
)
});
sheet
=
readStyleSheet
(
styleSheet
);
assert
(
...
...
src/vs/editor/test/browser/services/openerService.test.ts
浏览文件 @
cf77b6ea
...
...
@@ -7,24 +7,13 @@
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
assert
from
'
assert
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
import
{
TestCodeEditorService
}
from
'
vs/editor/test/browser/editorTestServices
'
;
import
{
ICommandService
,
NullCommandService
,
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
OpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
suite
(
'
OpenerService
'
,
function
()
{
let
lastInput
:
IResourceInput
;
const
editorService
=
new
class
implements
ITextEditorService
{
_serviceBrand
:
any
;
activeTextEditorControl
:
null
;
openTextEditor
(
input
:
IResourceInput
):
any
{
lastInput
=
input
;
return
TPromise
.
as
(
null
);
}
};
const
editorService
=
new
TestCodeEditorService
();
let
lastCommand
:
{
id
:
string
,
args
:
any
[]
};
...
...
@@ -38,14 +27,13 @@ suite('OpenerService', function () {
};
setup
(
function
()
{
lastInput
=
undefined
;
lastCommand
=
undefined
;
});
test
(
'
delegate to editorService, scheme:///fff
'
,
function
()
{
const
openerService
=
new
OpenerService
(
editorService
,
NullCommandService
);
openerService
.
open
(
URI
.
parse
(
'
another:///somepath
'
));
assert
.
equal
(
lastInput
.
options
.
selection
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
,
undefined
);
});
test
(
'
delegate to editorService, scheme:///fff#L123
'
,
function
()
{
...
...
@@ -53,22 +41,22 @@ suite('OpenerService', function () {
const
openerService
=
new
OpenerService
(
editorService
,
NullCommandService
);
openerService
.
open
(
URI
.
parse
(
'
file:///somepath#L23
'
));
assert
.
equal
(
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
lastInput
.
options
.
selection
.
startColumn
,
1
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
lastInput
.
resource
.
fragment
,
''
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startColumn
,
1
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
resource
.
fragment
,
''
);
openerService
.
open
(
URI
.
parse
(
'
another:///somepath#L23
'
));
assert
.
equal
(
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
lastInput
.
options
.
selection
.
startColumn
,
1
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startColumn
,
1
);
openerService
.
open
(
URI
.
parse
(
'
another:///somepath#L23,45
'
));
assert
.
equal
(
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
lastInput
.
options
.
selection
.
startColumn
,
45
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
lastInput
.
resource
.
fragment
,
''
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startColumn
,
45
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
resource
.
fragment
,
''
);
});
test
(
'
delegate to editorService, scheme:///fff#123,123
'
,
function
()
{
...
...
@@ -76,18 +64,18 @@ suite('OpenerService', function () {
const
openerService
=
new
OpenerService
(
editorService
,
NullCommandService
);
openerService
.
open
(
URI
.
parse
(
'
file:///somepath#23
'
));
assert
.
equal
(
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
lastInput
.
options
.
selection
.
startColumn
,
1
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
lastInput
.
resource
.
fragment
,
''
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startColumn
,
1
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
resource
.
fragment
,
''
);
openerService
.
open
(
URI
.
parse
(
'
file:///somepath#23,45
'
));
assert
.
equal
(
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
lastInput
.
options
.
selection
.
startColumn
,
45
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
lastInput
.
resource
.
fragment
,
''
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startLineNumber
,
23
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
startColumn
,
45
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endLineNumber
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
.
endColumn
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
resource
.
fragment
,
''
);
});
test
(
'
delegate to commandsService, command:someid
'
,
function
()
{
...
...
@@ -97,8 +85,8 @@ suite('OpenerService', function () {
// unknown command
openerService
.
open
(
URI
.
parse
(
'
command:foobar
'
));
assert
.
equal
(
lastCommand
,
undefined
);
assert
.
equal
(
lastInput
.
resource
.
toString
(),
'
command:foobar
'
);
assert
.
equal
(
lastInput
.
options
.
selection
,
undefined
);
assert
.
equal
(
editorService
.
lastInput
.
resource
.
toString
(),
'
command:foobar
'
);
assert
.
equal
(
editorService
.
lastInput
.
options
.
selection
,
undefined
);
const
id
=
`aCommand
${
Math
.
random
()}
`
;
CommandsRegistry
.
registerCommand
(
id
,
function
()
{
});
...
...
src/vs/workbench/electron-browser/shell.ts
浏览文件 @
cf77b6ea
...
...
@@ -36,7 +36,7 @@ import { LifecycleService } from 'vs/platform/lifecycle/electron-browser/lifecyc
import
{
MarkerService
}
from
'
vs/platform/markers/common/markerService
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
ModelServiceImpl
}
from
'
vs/editor/common/services/modelServiceImpl
'
;
import
{
CodeEditorService
Impl
}
from
'
vs/editor/browser/services/codeEditorServiceImpl
'
;
import
{
CodeEditorService
}
from
'
vs/workbench/services/codeEditor/browser/codeEditorService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
IntegrityServiceImpl
}
from
'
vs/platform/integrity/node/integrityServiceImpl
'
;
import
{
IIntegrityService
}
from
'
vs/platform/integrity/common/integrity
'
;
...
...
@@ -94,6 +94,8 @@ import { IDialogService } from 'vs/platform/dialogs/common/dialogs';
import
{
DialogService
}
from
'
vs/workbench/services/dialogs/electron-browser/dialogService
'
;
import
{
DialogChannel
}
from
'
vs/platform/dialogs/common/dialogIpc
'
;
import
{
EventType
,
addDisposableListener
,
addClass
,
getClientArea
}
from
'
vs/base/browser/dom
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
OpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
/**
* Services that we require for the Shell
...
...
@@ -456,7 +458,9 @@ export class WorkbenchShell {
serviceCollection
.
set
(
IWorkbenchIssueService
,
new
SyncDescriptor
(
WorkbenchIssueService
));
serviceCollection
.
set
(
ICodeEditorService
,
new
SyncDescriptor
(
CodeEditorServiceImpl
));
serviceCollection
.
set
(
ICodeEditorService
,
new
SyncDescriptor
(
CodeEditorService
));
serviceCollection
.
set
(
IOpenerService
,
new
SyncDescriptor
(
OpenerService
));
serviceCollection
.
set
(
IIntegrityService
,
new
SyncDescriptor
(
IntegrityServiceImpl
));
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
cf77b6ea
...
...
@@ -113,9 +113,6 @@ import { NextEditorPart } from 'vs/workbench/browser/parts/editor2/nextEditorPar
import
{
INextEditorGroupsService
,
GroupDirection
}
from
'
vs/workbench/services/group/common/nextEditorGroupsService
'
;
import
{
NextEditorService
}
from
'
vs/workbench/services/editor/browser/nextEditorService
'
;
import
{
IExtensionUrlHandler
,
ExtensionUrlHandler
}
from
'
vs/platform/url/electron-browser/inactiveExtensionUrlHandler
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
OpenerService
}
from
'
vs/editor/browser/services/openerService
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
interface
WorkbenchParams
{
configuration
:
IWindowConfiguration
;
...
...
@@ -389,10 +386,6 @@ export class Workbench extends Disposable implements IPartService {
serviceCollection
.
set
(
INextEditorGroupsService
,
this
.
editorPart
);
this
.
editorService
=
this
.
instantiationService
.
createInstance
(
NextEditorService
);
serviceCollection
.
set
(
INextEditorService
,
this
.
editorService
);
serviceCollection
.
set
(
ITextEditorService
,
this
.
editorService
);
// Opener service
serviceCollection
.
set
(
IOpenerService
,
new
SyncDescriptor
(
OpenerService
));
// TODO@grid Remove Legacy Editor Services
const
noOpEditorPart
=
new
NoOpEditorPart
(
this
.
instantiationService
);
...
...
src/vs/workbench/parts/codeEditor/electron-browser/workbenchReferenceSearch.ts
浏览文件 @
cf77b6ea
...
...
@@ -16,14 +16,14 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
ReferencesController
}
from
'
vs/editor/contrib/referenceSearch/referencesController
'
;
import
{
I
TextEditorService
}
from
'
vs/editor/browser/services/text
EditorService
'
;
import
{
I
CodeEditorService
}
from
'
vs/editor/browser/services/code
EditorService
'
;
export
class
WorkbenchReferencesController
extends
ReferencesController
{
public
constructor
(
editor
:
ICodeEditor
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
I
TextEditorService
textEditorService
:
IText
EditorService
,
@
I
CodeEditorService
codeEditorService
:
ICode
EditorService
,
@
ITextModelService
textModelResolverService
:
ITextModelService
,
@
INotificationService
notificationService
:
INotificationService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
...
...
@@ -37,7 +37,7 @@ export class WorkbenchReferencesController extends ReferencesController {
false
,
editor
,
contextKeyService
,
text
EditorService
,
code
EditorService
,
textModelResolverService
,
notificationService
,
instantiationService
,
...
...
src/vs/workbench/services/codeEditor/browser/codeEditorService.ts
0 → 100644
浏览文件 @
cf77b6ea
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
CodeEditorServiceImpl
}
from
'
vs/editor/browser/services/codeEditorServiceImpl
'
;
import
{
ICodeEditor
,
isCodeEditor
,
isDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IResourceInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
INextEditorService
,
SIDE_GROUP
,
ACTIVE_GROUP
}
from
'
vs/workbench/services/editor/common/nextEditorService
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
export
class
CodeEditorService
extends
CodeEditorServiceImpl
{
constructor
(
@
INextEditorService
private
editorService
:
INextEditorService
,
@
IThemeService
themeService
:
IThemeService
)
{
super
(
themeService
);
}
getActiveCodeEditor
():
ICodeEditor
{
let
activeEditor
=
this
.
editorService
.
activeTextEditorControl
;
if
(
isCodeEditor
(
activeEditor
))
{
return
activeEditor
;
}
if
(
isDiffEditor
(
activeEditor
))
{
return
activeEditor
.
getModifiedEditor
();
}
return
null
;
}
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
return
this
.
editorService
.
openEditor
(
input
,
sideBySide
?
SIDE_GROUP
:
ACTIVE_GROUP
).
then
(
control
=>
{
if
(
control
)
{
const
widget
=
control
.
getControl
();
if
(
isCodeEditor
(
widget
))
{
return
widget
;
}
}
return
null
;
});
}
}
\ No newline at end of file
src/vs/workbench/services/editor/browser/nextEditorService.ts
浏览文件 @
cf77b6ea
...
...
@@ -31,11 +31,10 @@ import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import
{
coalesce
}
from
'
vs/base/common/arrays
'
;
import
{
isCodeEditor
,
isDiffEditor
,
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IEditor
as
ITextEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
type
ICachedEditorInput
=
ResourceEditorInput
|
IFileEditorInput
|
DataUriEditorInput
;
export
class
NextEditorService
extends
Disposable
implements
INextEditorService
,
ITextEditorService
{
export
class
NextEditorService
extends
Disposable
implements
INextEditorService
{
_serviceBrand
:
any
;
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
cf77b6ea
...
...
@@ -73,7 +73,6 @@ import { INextEditorService } from 'vs/workbench/services/editor/common/nextEdit
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
ICodeEditor
,
IDiffEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IDecorationRenderOptions
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ITextEditorService
}
from
'
vs/editor/browser/services/textEditorService
'
;
export
function
createFileInput
(
instantiationService
:
IInstantiationService
,
resource
:
URI
):
FileEditorInput
{
return
instantiationService
.
createInstance
(
FileEditorInput
,
resource
,
void
0
);
...
...
@@ -281,7 +280,6 @@ export function workbenchInstantiationService(): IInstantiationService {
instantiationService
.
stub
(
INextEditorGroupsService
,
new
TestNextEditorGroupsService
([
new
TestNextEditorGroup
(
0
)]));
const
editorService
=
new
TestNextEditorService
();
instantiationService
.
stub
(
INextEditorService
,
editorService
);
instantiationService
.
stub
(
ITextEditorService
,
editorService
);
instantiationService
.
stub
(
ICodeEditorService
,
new
TestCodeEditorService
());
return
instantiationService
;
...
...
@@ -1133,6 +1131,8 @@ export class TestCodeEditorService implements ICodeEditorService {
resolveDecorationOptions
(
typeKey
:
string
,
writable
:
boolean
):
IModelDecorationOptions
{
return
Object
.
create
(
null
);
}
setTransientModelProperty
(
model
:
ITextModel
,
key
:
string
,
value
:
any
):
void
{
}
getTransientModelProperty
(
model
:
ITextModel
,
key
:
string
)
{
}
getActiveCodeEditor
():
ICodeEditor
{
return
null
;
}
openCodeEditor
(
input
:
IResourceInput
,
sideBySide
?:
boolean
):
TPromise
<
ICodeEditor
>
{
return
TPromise
.
as
(
null
);
}
}
export
class
TestWindowService
implements
IWindowService
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录