Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
307fda26
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,发现更多精彩内容 >>
提交
307fda26
编写于
4月 14, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Clarify extension host protocol
上级
922389d7
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
35 addition
and
22 deletion
+35
-22
src/vs/editor/common/model/mirrorModel2.ts
src/vs/editor/common/model/mirrorModel2.ts
+25
-2
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+2
-1
src/vs/workbench/api/node/extHostDocuments.ts
src/vs/workbench/api/node/extHostDocuments.ts
+2
-1
src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts
...nch/test/electron-browser/api/extHostDocumentData.test.ts
+4
-16
src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts
...ectron-browser/api/extHostDocumentSaveParticipant.test.ts
+2
-2
未找到文件。
src/vs/editor/common/model/mirrorModel2.ts
浏览文件 @
307fda26
...
...
@@ -5,9 +5,32 @@
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
I
ModelContentChangedEvent2
,
I
Position
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IPosition
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
export
interface
IModelChangedData
{
/**
* The range that got replaced.
*/
readonly
range
:
IRange
;
/**
* The length of the range that got replaced.
*/
readonly
rangeLength
:
number
;
/**
* The new text for the range.
*/
readonly
text
:
string
;
/**
* The (new) end-of-line character.
*/
readonly
eol
:
string
;
/**
* The new version id the model has transitioned to.
*/
readonly
versionId
:
number
;
}
export
class
MirrorModel2
{
protected
_uri
:
URI
;
...
...
@@ -35,7 +58,7 @@ export class MirrorModel2 {
return
this
.
_lines
.
join
(
this
.
_eol
);
}
onEvents
(
events
:
IModelC
ontentChangedEvent2
[]):
void
{
onEvents
(
events
:
IModelC
hangedData
[]):
void
{
let
newEOL
:
string
=
null
;
for
(
let
i
=
0
,
len
=
events
.
length
;
i
<
len
;
i
++
)
{
let
e
=
events
[
i
];
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
307fda26
...
...
@@ -38,6 +38,7 @@ import { IApplyEditsOptions, IUndoStopOptions, TextEditorRevealType, ITextEditor
import
{
InternalTreeExplorerNodeContent
}
from
'
vs/workbench/parts/explorers/common/treeExplorerViewModel
'
;
import
{
TaskSet
}
from
'
vs/workbench/parts/tasks/common/tasks
'
;
import
{
IModelChangedData
}
from
'
vs/editor/common/model/mirrorModel2
'
;
export
interface
IEnvironment
{
enableProposedApi
:
boolean
;
...
...
@@ -312,7 +313,7 @@ export abstract class ExtHostDocumentsShape {
$acceptModelSaved
(
strURL
:
string
):
void
{
throw
ni
();
}
$acceptModelDirty
(
strURL
:
string
):
void
{
throw
ni
();
}
$acceptModelReverted
(
strURL
:
string
):
void
{
throw
ni
();
}
$acceptModelChanged
(
strURL
:
string
,
events
:
editorCommon
.
IModelContentChangedEvent2
[],
isDirty
:
boolean
):
void
{
throw
ni
();
}
$acceptModelChanged
(
strURL
:
string
,
events
:
IModelChangedData
[],
isDirty
:
boolean
):
void
{
throw
ni
();
}
}
export
abstract
class
ExtHostDocumentSaveParticipantShape
{
...
...
src/vs/workbench/api/node/extHostDocuments.ts
浏览文件 @
307fda26
...
...
@@ -19,6 +19,7 @@ import { TextSource } from 'vs/editor/common/model/textSource';
import
{
MainContext
,
MainThreadDocumentsShape
,
ExtHostDocumentsShape
}
from
'
./extHost.protocol
'
;
import
{
ExtHostDocumentData
,
setWordDefinitionFor
}
from
'
./extHostDocumentData
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
./extHostDocumentsAndEditors
'
;
import
{
IModelChangedData
}
from
'
vs/editor/common/model/mirrorModel2
'
;
export
class
ExtHostDocuments
extends
ExtHostDocumentsShape
{
...
...
@@ -184,7 +185,7 @@ export class ExtHostDocuments extends ExtHostDocumentsShape {
document
.
_acceptIsDirty
(
false
);
}
public
$acceptModelChanged
(
strURL
:
string
,
events
:
editorCommon
.
IModelContentChangedEvent2
[],
isDirty
:
boolean
):
void
{
public
$acceptModelChanged
(
strURL
:
string
,
events
:
IModelChangedData
[],
isDirty
:
boolean
):
void
{
let
data
=
this
.
_documentsAndEditors
.
getDocument
(
strURL
);
data
.
_acceptIsDirty
(
isDirty
);
data
.
onEvents
(
events
);
...
...
src/vs/workbench/test/electron-browser/api/extHostDocumentData.test.ts
浏览文件 @
307fda26
...
...
@@ -10,9 +10,9 @@ import URI from 'vs/base/common/uri';
import
{
ExtHostDocumentData
}
from
'
vs/workbench/api/node/extHostDocumentData
'
;
import
{
Position
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
Range
as
CodeEditorRange
}
from
'
vs/editor/common/core/range
'
;
import
*
as
EditorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
MainThreadDocumentsShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IModelChangedData
}
from
'
vs/editor/common/model/mirrorModel2
'
;
suite
(
'
ExtHostDocumentData
'
,
()
=>
{
...
...
@@ -101,8 +101,6 @@ suite('ExtHostDocumentData', () => {
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
},
text
:
'
\t
'
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
versionId
:
undefined
,
rangeLength
:
undefined
,
}]);
...
...
@@ -157,8 +155,6 @@ suite('ExtHostDocumentData', () => {
range
:
{
startLineNumber
:
1
,
startColumn
:
3
,
endLineNumber
:
1
,
endColumn
:
6
},
text
:
''
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
versionId
:
undefined
,
rangeLength
:
undefined
,
}]);
...
...
@@ -174,8 +170,6 @@ suite('ExtHostDocumentData', () => {
range
:
{
startLineNumber
:
1
,
startColumn
:
3
,
endLineNumber
:
1
,
endColumn
:
6
},
text
:
'
is could be
'
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
versionId
:
undefined
,
rangeLength
:
undefined
,
}]);
...
...
@@ -191,8 +185,6 @@ suite('ExtHostDocumentData', () => {
range
:
{
startLineNumber
:
1
,
startColumn
:
3
,
endLineNumber
:
1
,
endColumn
:
6
},
text
:
'
is could be
\n
a line with number
'
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
versionId
:
undefined
,
rangeLength
:
undefined
,
}]);
...
...
@@ -211,8 +203,6 @@ suite('ExtHostDocumentData', () => {
range
:
{
startLineNumber
:
1
,
startColumn
:
3
,
endLineNumber
:
2
,
endColumn
:
6
},
text
:
''
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
versionId
:
undefined
,
rangeLength
:
undefined
,
}]);
...
...
@@ -311,19 +301,17 @@ suite('ExtHostDocumentData updates line mapping', () => {
}
}
function
createChangeEvent
(
range
:
CodeEditorRange
,
text
:
string
,
eol
?:
string
):
EditorCommon
.
IModelContentChangedEvent2
{
function
createChangeEvent
(
range
:
CodeEditorRange
,
text
:
string
,
eol
?:
string
):
IModelChangedData
{
return
{
range
:
range
,
text
:
text
,
eol
:
eol
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
versionId
:
undefined
,
rangeLength
:
undefined
,
};
}
function
testLineMappingDirectionAfterEvents
(
lines
:
string
[],
eol
:
string
,
direction
:
AssertDocumentLineMappingDirection
,
events
:
EditorCommon
.
IModelContentChangedEvent2
[]):
void
{
function
testLineMappingDirectionAfterEvents
(
lines
:
string
[],
eol
:
string
,
direction
:
AssertDocumentLineMappingDirection
,
events
:
IModelChangedData
[]):
void
{
let
myDocument
=
new
ExtHostDocumentData
(
undefined
,
URI
.
file
(
''
),
lines
.
slice
(
0
),
eol
,
'
text
'
,
1
,
false
);
assertDocumentLineMapping
(
myDocument
,
direction
);
...
...
@@ -331,7 +319,7 @@ suite('ExtHostDocumentData updates line mapping', () => {
assertDocumentLineMapping
(
myDocument
,
direction
);
}
function
testLineMappingAfterEvents
(
lines
:
string
[],
events
:
EditorCommon
.
IModelContentChangedEvent2
[]):
void
{
function
testLineMappingAfterEvents
(
lines
:
string
[],
events
:
IModelChangedData
[]):
void
{
testLineMappingDirectionAfterEvents
(
lines
,
'
\n
'
,
AssertDocumentLineMappingDirection
.
PositionToOffset
,
events
);
testLineMappingDirectionAfterEvents
(
lines
,
'
\n
'
,
AssertDocumentLineMappingDirection
.
OffsetToPosition
,
events
);
...
...
src/vs/workbench/test/electron-browser/api/extHostDocumentSaveParticipant.test.ts
浏览文件 @
307fda26
...
...
@@ -289,7 +289,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
versionId
:
2
,
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
},
text
:
'
bar
'
,
rangeLength
:
undefined
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
rangeLength
:
undefined
,
eol
:
undefined
}],
true
);
e
.
waitUntil
(
TPromise
.
as
([
TextEdit
.
insert
(
new
Position
(
0
,
0
),
'
bar
'
)]));
...
...
@@ -314,7 +314,7 @@ suite('ExtHostDocumentSaveParticipant', () => {
range
,
text
:
newText
,
versionId
:
documents
.
getDocumentData
(
resource
).
version
+
1
,
rangeLength
:
undefined
,
eol
:
undefined
,
isRedoing
:
undefined
,
isUndoing
:
undefined
,
rangeLength
:
undefined
,
eol
:
undefined
}],
true
);
}
return
TPromise
.
as
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录