Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
徽霖
Vscode
提交
45906d91
V
Vscode
项目概览
徽霖
/
Vscode
通知
9
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,发现更多精彩内容 >>
提交
45906d91
编写于
3月 09, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add ability to change a document's EOL
上级
e8d5a793
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
66 addition
and
19 deletion
+66
-19
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+21
-0
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+15
-13
src/vs/workbench/api/node/extHostEditors.ts
src/vs/workbench/api/node/extHostEditors.ts
+17
-5
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+5
-0
src/vs/workbench/api/node/mainThreadEditors.ts
src/vs/workbench/api/node/mainThreadEditors.ts
+8
-1
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
45906d91
...
@@ -796,6 +796,20 @@ declare namespace vscode {
...
@@ -796,6 +796,20 @@ declare namespace vscode {
hide
():
void
;
hide
():
void
;
}
}
/**
* Represents an end of line character sequence in a [document](#Document).
*/
export
enum
EndOfLine
{
/**
* The line feed `\n` character.
*/
LF
=
1
,
/**
* The carriage return line feed `\r\n` sequence.
*/
CRLF
=
2
}
/**
/**
* A complex edit that will be applied in one transaction on a TextEditor.
* A complex edit that will be applied in one transaction on a TextEditor.
* This holds a description of the edits and if the edits are valid (i.e. no overlapping regions, document was not changed in the meantime, etc.)
* This holds a description of the edits and if the edits are valid (i.e. no overlapping regions, document was not changed in the meantime, etc.)
...
@@ -828,6 +842,13 @@ declare namespace vscode {
...
@@ -828,6 +842,13 @@ declare namespace vscode {
* @param location The range this operation should remove.
* @param location The range this operation should remove.
*/
*/
delete
(
location
:
Range
|
Selection
):
void
;
delete
(
location
:
Range
|
Selection
):
void
;
/**
* Set the end of line sequence.
*
* @param endOfLine The new end of line for the [document](#Document).
*/
setEndOfLine
(
endOfLine
:
EndOfLine
):
void
;
}
}
/**
/**
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
45906d91
...
@@ -85,6 +85,7 @@ export class ExtHostAPIImplementation {
...
@@ -85,6 +85,7 @@ export class ExtHostAPIImplementation {
IndentAction
:
typeof
vscode
.
IndentAction
;
IndentAction
:
typeof
vscode
.
IndentAction
;
OverviewRulerLane
:
typeof
vscode
.
OverviewRulerLane
;
OverviewRulerLane
:
typeof
vscode
.
OverviewRulerLane
;
TextEditorRevealType
:
typeof
vscode
.
TextEditorRevealType
;
TextEditorRevealType
:
typeof
vscode
.
TextEditorRevealType
;
EndOfLine
:
typeof
vscode
.
EndOfLine
;
commands
:
typeof
vscode
.
commands
;
commands
:
typeof
vscode
.
commands
;
window
:
typeof
vscode
.
window
;
window
:
typeof
vscode
.
window
;
workspace
:
typeof
vscode
.
workspace
;
workspace
:
typeof
vscode
.
workspace
;
...
@@ -103,8 +104,8 @@ export class ExtHostAPIImplementation {
...
@@ -103,8 +104,8 @@ export class ExtHostAPIImplementation {
this
.
version
=
contextService
.
getConfiguration
().
env
.
version
;
this
.
version
=
contextService
.
getConfiguration
().
env
.
version
;
this
.
Uri
=
URI
;
this
.
Uri
=
URI
;
this
.
Location
=
extHostTypes
.
Location
;
this
.
Location
=
extHostTypes
.
Location
;
this
.
Diagnostic
=
<
any
>
extHostTypes
.
Diagnostic
;
this
.
Diagnostic
=
extHostTypes
.
Diagnostic
;
this
.
DiagnosticSeverity
=
<
any
>
extHostTypes
.
DiagnosticSeverity
;
this
.
DiagnosticSeverity
=
extHostTypes
.
DiagnosticSeverity
;
this
.
EventEmitter
=
Emitter
;
this
.
EventEmitter
=
Emitter
;
this
.
Disposable
=
extHostTypes
.
Disposable
;
this
.
Disposable
=
extHostTypes
.
Disposable
;
this
.
TextEdit
=
extHostTypes
.
TextEdit
;
this
.
TextEdit
=
extHostTypes
.
TextEdit
;
...
@@ -114,22 +115,23 @@ export class ExtHostAPIImplementation {
...
@@ -114,22 +115,23 @@ export class ExtHostAPIImplementation {
this
.
Selection
=
extHostTypes
.
Selection
;
this
.
Selection
=
extHostTypes
.
Selection
;
this
.
CancellationTokenSource
=
CancellationTokenSource
;
this
.
CancellationTokenSource
=
CancellationTokenSource
;
this
.
Hover
=
extHostTypes
.
Hover
;
this
.
Hover
=
extHostTypes
.
Hover
;
this
.
SymbolKind
=
<
any
>
extHostTypes
.
SymbolKind
;
this
.
SymbolKind
=
extHostTypes
.
SymbolKind
;
this
.
SymbolInformation
=
<
any
>
extHostTypes
.
SymbolInformation
;
this
.
SymbolInformation
=
extHostTypes
.
SymbolInformation
;
this
.
DocumentHighlightKind
=
<
any
>
extHostTypes
.
DocumentHighlightKind
;
this
.
DocumentHighlightKind
=
extHostTypes
.
DocumentHighlightKind
;
this
.
DocumentHighlight
=
<
any
>
extHostTypes
.
DocumentHighlight
;
this
.
DocumentHighlight
=
extHostTypes
.
DocumentHighlight
;
this
.
CodeLens
=
extHostTypes
.
CodeLens
;
this
.
CodeLens
=
extHostTypes
.
CodeLens
;
this
.
ParameterInformation
=
extHostTypes
.
ParameterInformation
;
this
.
ParameterInformation
=
extHostTypes
.
ParameterInformation
;
this
.
SignatureInformation
=
extHostTypes
.
SignatureInformation
;
this
.
SignatureInformation
=
extHostTypes
.
SignatureInformation
;
this
.
SignatureHelp
=
extHostTypes
.
SignatureHelp
;
this
.
SignatureHelp
=
extHostTypes
.
SignatureHelp
;
this
.
CompletionItem
=
<
any
>
extHostTypes
.
CompletionItem
;
this
.
CompletionItem
=
extHostTypes
.
CompletionItem
;
this
.
CompletionItemKind
=
<
any
>
extHostTypes
.
CompletionItemKind
;
this
.
CompletionItemKind
=
extHostTypes
.
CompletionItemKind
;
this
.
CompletionList
=
extHostTypes
.
CompletionList
;
this
.
CompletionList
=
extHostTypes
.
CompletionList
;
this
.
ViewColumn
=
<
any
>
extHostTypes
.
ViewColumn
;
this
.
ViewColumn
=
extHostTypes
.
ViewColumn
;
this
.
StatusBarAlignment
=
<
any
>
extHostTypes
.
StatusBarAlignment
;
this
.
StatusBarAlignment
=
extHostTypes
.
StatusBarAlignment
;
this
.
IndentAction
=
<
any
>
Modes
.
IndentAction
;
this
.
IndentAction
=
Modes
.
IndentAction
;
this
.
OverviewRulerLane
=
<
any
>
EditorCommon
.
OverviewRulerLane
;
this
.
OverviewRulerLane
=
EditorCommon
.
OverviewRulerLane
;
this
.
TextEditorRevealType
=
<
any
>
TextEditorRevealType
;
this
.
TextEditorRevealType
=
TextEditorRevealType
;
this
.
EndOfLine
=
extHostTypes
.
EndOfLine
;
errors
.
setUnexpectedErrorHandler
((
err
)
=>
{
errors
.
setUnexpectedErrorHandler
((
err
)
=>
{
this
.
_proxy
.
onUnexpectedExtHostError
(
errors
.
transformErrorForSerialization
(
err
));
this
.
_proxy
.
onUnexpectedExtHostError
(
errors
.
transformErrorForSerialization
(
err
));
...
...
src/vs/workbench/api/node/extHostEditors.ts
浏览文件 @
45906d91
...
@@ -10,7 +10,7 @@ import {IDisposable, disposeAll} from 'vs/base/common/lifecycle';
...
@@ -10,7 +10,7 @@ import {IDisposable, disposeAll} from 'vs/base/common/lifecycle';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
Remotable
,
IThreadService
}
from
'
vs/platform/thread/common/thread
'
;
import
{
ExtHostModelService
,
ExtHostDocumentData
}
from
'
vs/workbench/api/node/extHostDocuments
'
;
import
{
ExtHostModelService
,
ExtHostDocumentData
}
from
'
vs/workbench/api/node/extHostDocuments
'
;
import
{
Selection
,
Range
,
Position
,
EditorOptions
}
from
'
./extHostTypes
'
;
import
{
Selection
,
Range
,
Position
,
EditorOptions
,
EndOfLine
}
from
'
./extHostTypes
'
;
import
{
ISingleEditOperation
,
ISelection
,
IRange
,
IEditor
,
EditorType
,
ICommonCodeEditor
,
ICommonDiffEditor
,
IDecorationRenderOptions
,
IRangeWithMessage
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ISingleEditOperation
,
ISelection
,
IRange
,
IEditor
,
EditorType
,
ICommonCodeEditor
,
ICommonDiffEditor
,
IDecorationRenderOptions
,
IRangeWithMessage
}
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
@@ -196,22 +196,26 @@ export interface ITextEditOperation {
...
@@ -196,22 +196,26 @@ export interface ITextEditOperation {
export
interface
IEditData
{
export
interface
IEditData
{
documentVersionId
:
number
;
documentVersionId
:
number
;
edits
:
ITextEditOperation
[];
edits
:
ITextEditOperation
[];
setEndOfLine
:
EndOfLine
;
}
}
export
class
TextEditorEdit
{
export
class
TextEditorEdit
{
private
_documentVersionId
:
number
;
private
_documentVersionId
:
number
;
private
_collectedEdits
:
ITextEditOperation
[];
private
_collectedEdits
:
ITextEditOperation
[];
private
_setEndOfLine
:
EndOfLine
;
constructor
(
document
:
vscode
.
TextDocument
)
{
constructor
(
document
:
vscode
.
TextDocument
)
{
this
.
_documentVersionId
=
document
.
version
;
this
.
_documentVersionId
=
document
.
version
;
this
.
_collectedEdits
=
[];
this
.
_collectedEdits
=
[];
this
.
_setEndOfLine
=
0
;
}
}
finalize
():
IEditData
{
finalize
():
IEditData
{
return
{
return
{
documentVersionId
:
this
.
_documentVersionId
,
documentVersionId
:
this
.
_documentVersionId
,
edits
:
this
.
_collectedEdits
edits
:
this
.
_collectedEdits
,
setEndOfLine
:
this
.
_setEndOfLine
};
};
}
}
...
@@ -260,6 +264,14 @@ export class TextEditorEdit {
...
@@ -260,6 +264,14 @@ export class TextEditorEdit {
forceMoveMarkers
:
true
forceMoveMarkers
:
true
});
});
}
}
setEndOfLine
(
endOfLine
:
EndOfLine
):
void
{
if
(
endOfLine
!==
EndOfLine
.
LF
&&
endOfLine
!==
EndOfLine
.
CRLF
)
{
throw
illegalArg
(
'
endOfLine
'
);
}
this
.
_setEndOfLine
=
endOfLine
;
}
}
}
function
readonly
(
name
:
string
,
alt
?:
string
)
{
function
readonly
(
name
:
string
,
alt
?:
string
)
{
...
@@ -435,7 +447,7 @@ class ExtHostTextEditor implements vscode.TextEditor {
...
@@ -435,7 +447,7 @@ class ExtHostTextEditor implements vscode.TextEditor {
};
};
});
});
return
this
.
_proxy
.
_tryApplyEdits
(
this
.
_id
,
editData
.
documentVersionId
,
edits
);
return
this
.
_proxy
.
_tryApplyEdits
(
this
.
_id
,
editData
.
documentVersionId
,
edits
,
editData
.
setEndOfLine
);
}
}
// ---- util
// ---- util
...
@@ -705,11 +717,11 @@ export class MainThreadEditors {
...
@@ -705,11 +717,11 @@ export class MainThreadEditors {
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
_tryApplyEdits
(
id
:
string
,
modelVersionId
:
number
,
edits
:
ISingleEditOperation
[]):
TPromise
<
boolean
>
{
_tryApplyEdits
(
id
:
string
,
modelVersionId
:
number
,
edits
:
ISingleEditOperation
[]
,
setEndOfLine
:
EndOfLine
):
TPromise
<
boolean
>
{
if
(
!
this
.
_textEditorsMap
[
id
])
{
if
(
!
this
.
_textEditorsMap
[
id
])
{
return
TPromise
.
wrapError
(
'
TextEditor disposed
'
);
return
TPromise
.
wrapError
(
'
TextEditor disposed
'
);
}
}
return
TPromise
.
as
(
this
.
_textEditorsMap
[
id
].
applyEdits
(
modelVersionId
,
edits
));
return
TPromise
.
as
(
this
.
_textEditorsMap
[
id
].
applyEdits
(
modelVersionId
,
edits
,
setEndOfLine
));
}
}
_registerTextEditorDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
):
void
{
_registerTextEditorDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
):
void
{
...
...
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
45906d91
...
@@ -688,3 +688,8 @@ export enum StatusBarAlignment {
...
@@ -688,3 +688,8 @@ export enum StatusBarAlignment {
Left
=
1
,
Left
=
1
,
Right
=
2
Right
=
2
}
}
export
enum
EndOfLine
{
LF
=
1
,
CRLF
=
2
}
\ No newline at end of file
src/vs/workbench/api/node/mainThreadEditors.ts
浏览文件 @
45906d91
...
@@ -13,6 +13,7 @@ import {IDisposable, disposeAll} from 'vs/base/common/lifecycle';
...
@@ -13,6 +13,7 @@ import {IDisposable, disposeAll} from 'vs/base/common/lifecycle';
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
{
EndOfLine
}
from
'
vs/workbench/api/node/extHostTypes
'
;
export
interface
ITextEditorConfigurationUpdate
{
export
interface
ITextEditorConfigurationUpdate
{
tabSize
?:
number
|
string
;
tabSize
?:
number
|
string
;
...
@@ -262,7 +263,7 @@ export class MainThreadTextEditor {
...
@@ -262,7 +263,7 @@ export class MainThreadTextEditor {
return
editor
.
getControl
()
===
this
.
_codeEditor
;
return
editor
.
getControl
()
===
this
.
_codeEditor
;
}
}
public
applyEdits
(
versionIdCheck
:
number
,
edits
:
EditorCommon
.
ISingleEditOperation
[]):
boolean
{
public
applyEdits
(
versionIdCheck
:
number
,
edits
:
EditorCommon
.
ISingleEditOperation
[]
,
setEndOfLine
:
EndOfLine
):
boolean
{
if
(
this
.
_model
.
getVersionId
()
!==
versionIdCheck
)
{
if
(
this
.
_model
.
getVersionId
()
!==
versionIdCheck
)
{
console
.
warn
(
'
Model has changed in the meantime!
'
);
console
.
warn
(
'
Model has changed in the meantime!
'
);
// throw new Error('Model has changed in the meantime!');
// throw new Error('Model has changed in the meantime!');
...
@@ -271,6 +272,12 @@ export class MainThreadTextEditor {
...
@@ -271,6 +272,12 @@ export class MainThreadTextEditor {
}
}
if
(
this
.
_codeEditor
)
{
if
(
this
.
_codeEditor
)
{
if
(
setEndOfLine
===
EndOfLine
.
CRLF
)
{
this
.
_model
.
setEOL
(
EditorCommon
.
EndOfLineSequence
.
CRLF
);
}
else
if
(
setEndOfLine
===
EndOfLine
.
LF
)
{
this
.
_model
.
setEOL
(
EditorCommon
.
EndOfLineSequence
.
LF
);
}
let
transformedEdits
=
edits
.
map
((
edit
):
EditorCommon
.
IIdentifiedSingleEditOperation
=>
{
let
transformedEdits
=
edits
.
map
((
edit
):
EditorCommon
.
IIdentifiedSingleEditOperation
=>
{
return
{
return
{
identifier
:
null
,
identifier
:
null
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录