Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
57bb9407
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,发现更多精彩内容 >>
提交
57bb9407
编写于
3月 09, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add `EndOfLineEdit` and allow it to be returned from onWillSave
上级
ac0e3c61
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
73 addition
and
23 deletion
+73
-23
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+23
-1
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+1
-0
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+2
-2
src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts
src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts
+14
-7
src/vs/workbench/api/node/extHostTypeConverters.ts
src/vs/workbench/api/node/extHostTypeConverters.ts
+16
-5
src/vs/workbench/api/node/extHostTypes.ts
src/vs/workbench/api/node/extHostTypes.ts
+15
-6
src/vs/workbench/api/node/mainThreadWorkspace.ts
src/vs/workbench/api/node/mainThreadWorkspace.ts
+2
-2
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
57bb9407
...
...
@@ -1997,6 +1997,28 @@ declare module 'vscode' {
provideReferences
(
document
:
TextDocument
,
position
:
Position
,
context
:
ReferenceContext
,
token
:
CancellationToken
):
ProviderResult
<
Location
[]
>
;
}
/**
* An end-of-line edit represents a change of the [sequence](#TextDocument.eol)
* that separates the lines in a document.
*/
export
class
EndOfLineEdit
{
/**
* Use the line feed `\n` character.
*/
static
readonly
LF
:
EndOfLineEdit
;
/**
* Use the carriage return line feed `\r\n` sequence.
*/
static
readonly
CRLF
:
EndOfLineEdit
;
/**
* The new end of line sequence
*/
newEol
:
EndOfLine
;
}
/**
* A text edit represents edits that should be applied
* to a document.
...
...
@@ -3962,7 +3984,7 @@ declare module 'vscode' {
*
* @param thenable A thenable that resolves to [pre-save-edits](#TextEdit).
*/
waitUntil
(
thenable
:
Thenable
<
TextEdit
[]
>
):
void
;
waitUntil
(
thenable
:
Thenable
<
TextEdit
[]
|
EndOfLineEdit
>
):
void
;
/**
* Allows to pause the event loop until the provided thenable resolved.
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
57bb9407
...
...
@@ -486,6 +486,7 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
SymbolKind
:
extHostTypes
.
SymbolKind
,
TextDocumentSaveReason
:
extHostTypes
.
TextDocumentSaveReason
,
TextEdit
:
extHostTypes
.
TextEdit
,
EndOfLineEdit
:
extHostTypes
.
EndOfLineEdit
,
TextEditorCursorStyle
:
EditorCommon
.
TextEditorCursorStyle
,
TextEditorLineNumbersStyle
:
extHostTypes
.
TextEditorLineNumbersStyle
,
TextEditorRevealType
:
extHostTypes
.
TextEditorRevealType
,
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
57bb9407
...
...
@@ -26,7 +26,7 @@ import { IWorkspace } from 'vs/platform/workspace/common/workspace';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
IResource
Text
Edit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
IResourceEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
ITextSource
}
from
'
vs/editor/common/model/textSource
'
;
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
...
...
@@ -234,7 +234,7 @@ export abstract class MainThreadWorkspaceShape {
$startSearch
(
include
:
string
,
exclude
:
string
,
maxResults
:
number
,
requestId
:
number
):
Thenable
<
URI
[]
>
{
throw
ni
();
}
$cancelSearch
(
requestId
:
number
):
Thenable
<
boolean
>
{
throw
ni
();
}
$saveAll
(
includeUntitled
?:
boolean
):
Thenable
<
boolean
>
{
throw
ni
();
}
$applyWorkspaceEdit
(
edits
:
IResource
Text
Edit
[]):
TPromise
<
boolean
>
{
throw
ni
();
}
$applyWorkspaceEdit
(
edits
:
IResourceEdit
[]):
TPromise
<
boolean
>
{
throw
ni
();
}
}
export
abstract
class
MainProcessExtensionServiceShape
{
...
...
src/vs/workbench/api/node/extHostDocumentSaveParticipant.ts
浏览文件 @
57bb9407
...
...
@@ -11,9 +11,9 @@ import { sequence, always } from 'vs/base/common/async';
import
{
illegalState
}
from
'
vs/base/common/errors
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
MainThreadWorkspaceShape
,
ExtHostDocumentSaveParticipantShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
TextEdit
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
fromRange
,
TextDocumentSaveReason
}
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
import
{
IResource
Text
Edit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
TextEdit
,
EndOfLineEdit
}
from
'
vs/workbench/api/node/extHostTypes
'
;
import
{
fromRange
,
TextDocumentSaveReason
,
fromEOL
}
from
'
vs/workbench/api/node/extHostTypeConverters
'
;
import
{
IResourceEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
ExtHostDocuments
}
from
'
vs/workbench/api/node/extHostDocuments
'
;
import
{
SaveReason
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
*
as
vscode
from
'
vscode
'
;
...
...
@@ -101,7 +101,7 @@ export class ExtHostDocumentSaveParticipant extends ExtHostDocumentSaveParticipa
private
_deliverEventAsync
(
listener
:
Function
,
thisArg
:
any
,
stubEvent
:
vscode
.
TextDocumentWillSaveEvent
):
TPromise
<
any
>
{
const
promises
:
TPromise
<
any
|
vscode
.
TextEdit
[]
>
[]
=
[];
const
promises
:
TPromise
<
vscode
.
TextEdit
[]
|
vscode
.
EndOfLineEdit
>
[]
=
[];
const
{
document
,
reason
}
=
stubEvent
;
const
{
version
}
=
document
;
...
...
@@ -127,16 +127,23 @@ export class ExtHostDocumentSaveParticipant extends ExtHostDocumentSaveParticipa
// freeze promises after event call
Object
.
freeze
(
promises
);
return
new
TPromise
<
any
[]
>
((
resolve
,
reject
)
=>
{
return
new
TPromise
<
(
vscode
.
TextEdit
[]
|
vscode
.
EndOfLineEdit
)
[]
>
((
resolve
,
reject
)
=>
{
// join on all listener promises, reject after timeout
const
handle
=
setTimeout
(()
=>
reject
(
new
Error
(
'
timeout
'
)),
this
.
_thresholds
.
timeout
);
return
always
(
TPromise
.
join
(
promises
),
()
=>
clearTimeout
(
handle
)).
then
(
resolve
,
reject
);
}).
then
(
values
=>
{
const
edits
:
IResourceTextEdit
[]
=
[];
let
edits
:
IResourceEdit
[]
=
[];
for
(
const
value
of
values
)
{
if
(
Array
.
isArray
(
value
)
&&
(
<
vscode
.
TextEdit
[]
>
value
).
every
(
e
=>
e
instanceof
TextEdit
))
{
if
(
value
instanceof
EndOfLineEdit
)
{
edits
.
push
({
resource
:
<
URI
>
document
.
uri
,
eol
:
fromEOL
(
value
.
newEol
)
});
}
else
if
(
Array
.
isArray
(
value
)
&&
(
<
vscode
.
TextEdit
[]
>
value
).
every
(
e
=>
e
instanceof
TextEdit
))
{
for
(
const
{
newText
,
range
}
of
value
)
{
edits
.
push
({
resource
:
<
URI
>
document
.
uri
,
...
...
src/vs/workbench/api/node/extHostTypeConverters.ts
浏览文件 @
57bb9407
...
...
@@ -8,7 +8,7 @@ import Severity from 'vs/base/common/severity';
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
*
as
types
from
'
./extHostTypes
'
;
import
{
Position
as
EditorPosition
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IPosition
,
ISelection
,
IRange
,
IDecorationOptions
,
ISingleEditOperation
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IPosition
,
ISelection
,
IRange
,
IDecorationOptions
,
ISingleEditOperation
,
EndOfLineSequence
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IWorkspaceSymbol
}
from
'
vs/workbench/parts/search/common/search
'
;
import
*
as
vscode
from
'
vscode
'
;
import
URI
from
'
vs/base/common/uri
'
;
...
...
@@ -30,14 +30,14 @@ export interface SelectionLike extends RangeLike {
}
export
function
toSelection
(
selection
:
ISelection
):
types
.
Selection
{
let
{
selectionStartLineNumber
,
selectionStartColumn
,
positionLineNumber
,
positionColumn
}
=
selection
;
let
{
selectionStartLineNumber
,
selectionStartColumn
,
positionLineNumber
,
positionColumn
}
=
selection
;
let
start
=
new
types
.
Position
(
selectionStartLineNumber
-
1
,
selectionStartColumn
-
1
);
let
end
=
new
types
.
Position
(
positionLineNumber
-
1
,
positionColumn
-
1
);
return
new
types
.
Selection
(
start
,
end
);
}
export
function
fromSelection
(
selection
:
SelectionLike
):
ISelection
{
let
{
anchor
,
active
}
=
selection
;
let
{
anchor
,
active
}
=
selection
;
return
{
selectionStartLineNumber
:
anchor
.
line
+
1
,
selectionStartColumn
:
anchor
.
character
+
1
,
...
...
@@ -47,7 +47,7 @@ export function fromSelection(selection: SelectionLike): ISelection {
}
export
function
fromRange
(
range
:
RangeLike
):
IRange
{
let
{
start
,
end
}
=
range
;
let
{
start
,
end
}
=
range
;
return
{
startLineNumber
:
start
.
line
+
1
,
startColumn
:
start
.
character
+
1
,
...
...
@@ -57,7 +57,7 @@ export function fromRange(range: RangeLike): IRange {
}
export
function
toRange
(
range
:
IRange
):
types
.
Range
{
let
{
startLineNumber
,
startColumn
,
endLineNumber
,
endColumn
}
=
range
;
let
{
startLineNumber
,
startColumn
,
endLineNumber
,
endColumn
}
=
range
;
return
new
types
.
Range
(
startLineNumber
-
1
,
startColumn
-
1
,
endLineNumber
-
1
,
endColumn
-
1
);
}
...
...
@@ -345,3 +345,14 @@ export namespace TextDocumentSaveReason {
}
}
}
export
function
fromEOL
(
eol
:
vscode
.
EndOfLine
):
EndOfLineSequence
{
if
(
eol
===
types
.
EndOfLine
.
CRLF
)
{
return
EndOfLineSequence
.
CRLF
;
}
else
if
(
eol
===
types
.
EndOfLine
.
LF
)
{
return
EndOfLineSequence
.
LF
;
}
return
undefined
;
}
src/vs/workbench/api/node/extHostTypes.ts
浏览文件 @
57bb9407
...
...
@@ -66,7 +66,7 @@ export class Position {
if
(
other
instanceof
Position
)
{
return
true
;
}
let
{
line
,
character
}
=
<
Position
>
other
;
let
{
line
,
character
}
=
<
Position
>
other
;
if
(
typeof
line
===
'
number
'
&&
typeof
character
===
'
number
'
)
{
return
true
;
}
...
...
@@ -399,6 +399,20 @@ export class Selection extends Range {
}
}
export
enum
EndOfLine
{
LF
=
1
,
CRLF
=
2
}
export
class
EndOfLineEdit
{
static
readonly
LF
:
EndOfLineEdit
=
Object
.
freeze
({
newEol
:
EndOfLine
.
LF
});
static
readonly
CRLF
:
EndOfLineEdit
=
Object
.
freeze
({
newEol
:
EndOfLine
.
CRLF
});
newEol
:
EndOfLine
;
}
export
class
TextEdit
{
static
isTextEdit
(
thing
:
any
):
thing
is
TextEdit
{
...
...
@@ -900,11 +914,6 @@ export enum StatusBarAlignment {
Right
=
2
}
export
enum
EndOfLine
{
LF
=
1
,
CRLF
=
2
}
export
enum
TextEditorLineNumbersStyle
{
Off
=
0
,
On
=
1
,
...
...
src/vs/workbench/api/node/mainThreadWorkspace.ts
浏览文件 @
57bb9407
...
...
@@ -10,7 +10,7 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
ICommonCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
bulkEdit
,
IResource
Text
Edit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
bulkEdit
,
IResourceEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Uri
}
from
'
vscode
'
;
import
{
MainThreadWorkspaceShape
}
from
'
./extHost.protocol
'
;
...
...
@@ -89,7 +89,7 @@ export class MainThreadWorkspace extends MainThreadWorkspaceShape {
});
}
$applyWorkspaceEdit
(
edits
:
IResource
Text
Edit
[]):
TPromise
<
boolean
>
{
$applyWorkspaceEdit
(
edits
:
IResourceEdit
[]):
TPromise
<
boolean
>
{
let
codeEditor
:
ICommonCodeEditor
;
let
editor
=
this
.
_editorService
.
getActiveEditor
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录