Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
2876e9cc
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,发现更多精彩内容 >>
提交
2876e9cc
编写于
10月 05, 2016
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
some fixes around usage of file editor input
上级
7e299e73
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
37 addition
and
43 deletion
+37
-43
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+10
-10
src/vs/workbench/parts/files/browser/editors/binaryFileEditor.ts
...workbench/parts/files/browser/editors/binaryFileEditor.ts
+1
-1
src/vs/workbench/parts/files/browser/fileActions.ts
src/vs/workbench/parts/files/browser/fileActions.ts
+4
-3
src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts
.../workbench/parts/files/browser/views/openEditorsViewer.ts
+3
-9
src/vs/workbench/parts/git/browser/views/changes/changesView.ts
.../workbench/parts/git/browser/views/changes/changesView.ts
+2
-3
src/vs/workbench/test/common/editor/rangeDecorations.test.ts
src/vs/workbench/test/common/editor/rangeDecorations.test.ts
+17
-17
未找到文件。
src/vs/workbench/common/editor.ts
浏览文件 @
2876e9cc
...
...
@@ -459,7 +459,7 @@ export class EditorOptions implements IEditorOptions {
* Helper to create EditorOptions inline.
*/
public
static
create
(
settings
:
IEditorOptions
):
EditorOptions
{
le
t
options
=
new
EditorOptions
();
cons
t
options
=
new
EditorOptions
();
options
.
preserveFocus
=
settings
.
preserveFocus
;
options
.
forceOpen
=
settings
.
forceOpen
;
options
.
revealIfVisible
=
settings
.
revealIfVisible
;
...
...
@@ -537,7 +537,7 @@ export class TextEditorOptions extends EditorOptions {
}
if
(
input
.
options
.
selection
)
{
le
t
selection
=
input
.
options
.
selection
;
cons
t
selection
=
input
.
options
.
selection
;
options
.
selection
(
selection
.
startLineNumber
,
selection
.
startColumn
,
selection
.
endLineNumber
,
selection
.
endColumn
);
}
...
...
@@ -573,7 +573,7 @@ export class TextEditorOptions extends EditorOptions {
* Helper to create TextEditorOptions inline.
*/
public
static
create
(
settings
:
ITextEditorOptions
):
TextEditorOptions
{
le
t
options
=
new
TextEditorOptions
();
cons
t
options
=
new
TextEditorOptions
();
options
.
preserveFocus
=
settings
.
preserveFocus
;
options
.
forceOpen
=
settings
.
forceOpen
;
options
.
revealIfVisible
=
settings
.
revealIfVisible
;
...
...
@@ -660,7 +660,7 @@ export class TextEditorOptions extends EditorOptions {
// Select
if
(
!
types
.
isUndefinedOrNull
(
this
.
endLineNumber
)
&&
!
types
.
isUndefinedOrNull
(
this
.
endColumn
))
{
le
t
range
=
{
cons
t
range
=
{
startLineNumber
:
this
.
startLineNumber
,
startColumn
:
this
.
startColumn
,
endLineNumber
:
this
.
endLineNumber
,
...
...
@@ -672,7 +672,7 @@ export class TextEditorOptions extends EditorOptions {
// Reveal
else
{
le
t
pos
=
{
cons
t
pos
=
{
lineNumber
:
this
.
startLineNumber
,
column
:
this
.
startColumn
};
...
...
@@ -705,7 +705,7 @@ export class TextDiffEditorOptions extends TextEditorOptions {
* Helper to create TextDiffEditorOptions inline.
*/
public
static
create
(
settings
:
ITextDiffEditorOptions
):
TextDiffEditorOptions
{
le
t
options
=
new
TextDiffEditorOptions
();
cons
t
options
=
new
TextDiffEditorOptions
();
options
.
autoRevealFirstChange
=
settings
.
autoRevealFirstChange
;
...
...
@@ -746,7 +746,7 @@ export function getUntitledOrFileResource(input: IEditorInput, supportDiff?: boo
}
// File
le
t
fileInput
=
asFileEditorInput
(
input
,
supportDiff
);
cons
t
fileInput
=
asFileEditorInput
(
input
,
supportDiff
);
return
fileInput
&&
fileInput
.
getResource
();
}
...
...
@@ -754,7 +754,7 @@ export function getUntitledOrFileResource(input: IEditorInput, supportDiff?: boo
// TODO@Ben every editor should have an associated resource
export
function
getResource
(
input
:
IEditorInput
):
URI
{
if
(
input
instanceof
EditorInput
&&
typeof
(
<
any
>
input
).
getResource
===
'
function
'
)
{
le
t
candidate
=
(
<
any
>
input
).
getResource
();
cons
t
candidate
=
(
<
any
>
input
).
getResource
();
if
(
candidate
instanceof
URI
)
{
return
candidate
;
}
...
...
@@ -795,9 +795,9 @@ export function asFileEditorInput(obj: any, supportDiff?: boolean): IFileEditorI
obj
=
(
<
BaseDiffEditorInput
>
obj
).
modifiedInput
;
}
le
t
i
=
<
IFileEditorInput
>
obj
;
cons
t
i
=
<
IFileEditorInput
>
obj
;
return
i
instanceof
EditorInput
&&
types
.
areFunctions
(
i
.
setResource
,
i
.
setEncoding
,
i
.
getEncoding
,
i
.
getResource
)
?
i
:
null
;
return
i
instanceof
EditorInput
&&
types
.
areFunctions
(
i
.
setResource
,
i
.
setEncoding
,
i
.
getEncoding
,
i
.
getResource
,
i
.
setPreferredEncoding
)
?
i
:
null
;
}
export
interface
IStacksModelChangeEvent
{
...
...
src/vs/workbench/parts/files/browser/editors/binaryFileEditor.ts
浏览文件 @
2876e9cc
...
...
@@ -11,7 +11,7 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
/**
* An implementation of editor for binary files like images
or videos leveraging the FileEditorInput
.
* An implementation of editor for binary files like images.
*/
export
class
BinaryFileEditor
extends
BaseBinaryResourceEditor
{
...
...
src/vs/workbench/parts/files/browser/fileActions.ts
浏览文件 @
2876e9cc
...
...
@@ -26,7 +26,7 @@ import {dispose, IDisposable} from 'vs/base/common/lifecycle';
import
{
LocalFileChangeEvent
,
VIEWLET_ID
,
ITextFileService
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IFileService
,
IFileStat
,
IImportResult
}
from
'
vs/platform/files/common/files
'
;
import
{
DiffEditorInput
,
toDiffLabel
}
from
'
vs/workbench/common/editor/diffEditorInput
'
;
import
{
asFileEditorInput
,
getUntitledOrFileResource
,
UntitledEditorInput
,
IEditorIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
asFileEditorInput
,
getUntitledOrFileResource
,
IEditorIdentifier
}
from
'
vs/workbench/common/editor
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
import
{
FileStat
,
NewStatPlaceholder
}
from
'
vs/workbench/parts/files/common/explorerViewModel
'
;
import
{
ExplorerView
}
from
'
vs/workbench/parts/files/browser/views/explorerView
'
;
...
...
@@ -1633,8 +1633,9 @@ export class SaveAllInGroupAction extends BaseSaveAllAction {
const
editorGroup
=
editorIdentifier
.
group
;
const
resourcesToSave
=
[];
editorGroup
.
getEditors
().
forEach
(
editor
=>
{
if
(
editor
instanceof
FileEditorInput
||
editor
instanceof
UntitledEditorInput
)
{
resourcesToSave
.
push
(
editor
.
getResource
());
const
resource
=
getUntitledOrFileResource
(
editor
,
true
);
if
(
resource
)
{
resourcesToSave
.
push
(
resource
);
}
});
...
...
src/vs/workbench/parts/files/browser/views/openEditorsViewer.ts
浏览文件 @
2876e9cc
...
...
@@ -22,9 +22,9 @@ import {ITelemetryService} from 'vs/platform/telemetry/common/telemetry';
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
UntitledEditorInput
,
IEditorGroup
,
IEditorStacksModel
}
from
'
vs/workbench/common/editor
'
;
import
{
UntitledEditorInput
,
IEditorGroup
,
IEditorStacksModel
,
getUntitledOrFileResource
}
from
'
vs/workbench/common/editor
'
;
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
ITextFileService
,
AutoSaveMode
,
FileEditorInput
,
asFileResource
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
ITextFileService
,
AutoSaveMode
,
asFileResource
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
EditorStacksModel
,
EditorGroup
}
from
'
vs/workbench/common/editor/editorStacksModel
'
;
import
{
keybindingForAction
,
SaveFileAction
,
RevertFileAction
,
SaveFileAsAction
,
OpenToSideAction
,
SelectResourceForCompareAction
,
CompareResourcesAction
,
SaveAllInGroupAction
}
from
'
vs/workbench/parts/files/browser/fileActions
'
;
...
...
@@ -64,13 +64,7 @@ export class OpenEditor {
}
public
getResource
():
uri
{
if
(
this
.
editor
instanceof
FileEditorInput
)
{
return
(
<
FileEditorInput
>
this
.
editor
).
getResource
();
}
else
if
(
this
.
editor
instanceof
UntitledEditorInput
)
{
return
(
<
UntitledEditorInput
>
this
.
editor
).
getResource
();
}
return
null
;
return
getUntitledOrFileResource
(
this
.
editor
,
true
);
}
}
...
...
src/vs/workbench/parts/git/browser/views/changes/changesView.ts
浏览文件 @
2876e9cc
...
...
@@ -26,7 +26,6 @@ import GitActions = require('vs/workbench/parts/git/browser/gitActions');
import
GitModel
=
require
(
'
vs/workbench/parts/git/common/gitModel
'
);
import
Viewer
=
require
(
'
vs/workbench/parts/git/browser/views/changes/changesViewer
'
);
import
GitEditorInputs
=
require
(
'
vs/workbench/parts/git/browser/gitEditorInputs
'
);
import
Files
=
require
(
'
vs/workbench/parts/files/common/files
'
);
import
{
IOutputService
}
from
'
vs/workbench/parts/output/common/output
'
;
import
WorkbenchEditorCommon
=
require
(
'
vs/workbench/common/editor
'
);
import
InputBox
=
require
(
'
vs/base/browser/ui/inputbox/inputBox
'
);
...
...
@@ -450,8 +449,8 @@ export class ChangesView extends EventEmitter.EventEmitter implements GitView.IV
return
(
<
GitEditorInputs
.
NativeGitIndexStringEditorInput
>
input
).
getFileStatus
()
||
null
;
}
if
(
input
instanceof
Files
.
FileEditorInput
)
{
const
fileInput
=
<
Files
.
FileEditorInput
>
input
;
const
fileInput
=
WorkbenchEditorCommon
.
asFileEditorInput
(
input
);
if
(
fileInput
)
{
const
resource
=
fileInput
.
getResource
();
const
workspaceRoot
=
this
.
contextService
.
getWorkspace
().
resource
.
fsPath
;
...
...
src/vs/workbench/test/common/editor/rangeDecorations.test.ts
浏览文件 @
2876e9cc
...
...
@@ -6,20 +6,20 @@
import
*
as
assert
from
'
assert
'
;
import
{
TestInstantiationService
}
from
'
vs/test/utils/instantiationTestUtils
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
createMockModelService
,
TestEditorService
,
workbenchInstantiationService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
createMockModelService
,
TestEditorService
,
workbenchInstantiationService
}
from
'
vs/test/utils/servicesTestUtils
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
WorkbenchEditorService
=
require
(
'
vs/workbench/services/editor/common/editorService
'
);
import
{
RangeHighlightDecorations
}
from
'
vs/workbench/common/editor/rangeDecorations
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
mockCodeEditor
,
MockCodeEditor
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
{
Model
}
from
'
vs/editor/common/model/model
'
;
import
{
mockCodeEditor
,
MockCodeEditor
}
from
'
vs/editor/test/common/mocks/mockCodeEditor
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
import
{
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
FileEditorInput
}
from
'
vs/workbench/parts/files/common/editors/fileEditorInput
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
Cursor
}
from
'
vs/editor/common/controller/cursor
'
;
suite
(
'
Editor - Range decorations
'
,
()
=>
{
...
...
@@ -36,8 +36,8 @@ suite('Editor - Range decorations', () => {
setup
(()
=>
{
instantiationService
=
<
TestInstantiationService
>
workbenchInstantiationService
();
editorService
=
<
WorkbenchEditorService
.
IWorkbenchEditorService
>
instantiationService
.
stub
(
WorkbenchEditorService
.
IWorkbenchEditorService
,
new
TestEditorService
(
function
()
{
}));
modeService
=
instantiationService
.
stub
(
IModeService
);
editorService
=
<
WorkbenchEditorService
.
IWorkbenchEditorService
>
instantiationService
.
stub
(
WorkbenchEditorService
.
IWorkbenchEditorService
,
new
TestEditorService
(
function
()
{
}));
modeService
=
instantiationService
.
stub
(
IModeService
);
modelService
=
<
IModelService
>
instantiationService
.
stub
(
IModelService
,
createMockModelService
(
instantiationService
));
text
=
'
LINE1
'
+
'
\n
'
+
'
LINE2
'
+
'
\n
'
+
'
LINE3
'
+
'
\n
'
+
'
LINE4
'
+
'
\r\n
'
+
'
LINE5
'
;
model
=
aModel
(
URI
.
file
(
'
some_file
'
));
...
...
@@ -65,7 +65,7 @@ suite('Editor - Range decorations', () => {
});
test
(
'
remove highlight range
'
,
function
()
{
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
}});
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
}
});
testObject
.
removeHighlightRange
();
let
actuals
=
rangeHighlightDecorations
(
model
);
...
...
@@ -74,7 +74,7 @@ suite('Editor - Range decorations', () => {
});
test
(
'
highlight range for the resource removes previous highlight
'
,
function
()
{
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
}});
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
}
});
let
range
:
editorCommon
.
IRange
=
{
startLineNumber
:
2
,
startColumn
:
2
,
endLineNumber
:
4
,
endColumn
:
3
};
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
});
...
...
@@ -124,7 +124,7 @@ suite('Editor - Range decorations', () => {
test
(
'
previous highlight is not removed if not active editor
'
,
function
()
{
let
range
:
editorCommon
.
IRange
=
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
};
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
});
testObject
.
highlightRange
({
resource
:
model
.
uri
,
range
});
let
model1
=
aModel
(
URI
.
file
(
'
some model
'
));
testObject
.
highlightRange
({
resource
:
model1
.
uri
,
range
:
{
startLineNumber
:
2
,
startColumn
:
1
,
endLineNumber
:
2
,
endColumn
:
1
}
});
...
...
@@ -150,7 +150,7 @@ suite('Editor - Range decorations', () => {
function
mockEditorService
(
resource
:
URI
)
function
mockEditorService
(
arg
:
any
)
{
let
editorInput
:
IEditorInput
=
arg
instanceof
URI
?
instantiationService
.
createInstance
(
FileEditorInput
,
arg
,
void
0
)
:
arg
;
instantiationService
.
stub
(
WorkbenchEditorService
.
IWorkbenchEditorService
,
'
getActiveEditorInput
'
,
editorInput
);
instantiationService
.
stub
(
WorkbenchEditorService
.
IWorkbenchEditorService
,
'
getActiveEditorInput
'
,
editorInput
);
}
function
rangeHighlightDecorations
(
m
:
Model
):
editorCommon
.
IRange
[]
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录