Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e74a5aa3
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,发现更多精彩内容 >>
提交
e74a5aa3
编写于
7月 06, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #8804
上级
eca4e3b0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
25 addition
and
36 deletion
+25
-36
src/vs/workbench/parts/git/browser/gitActions.contribution.ts
...vs/workbench/parts/git/browser/gitActions.contribution.ts
+15
-4
src/vs/workbench/parts/git/common/stageRanges.ts
src/vs/workbench/parts/git/common/stageRanges.ts
+10
-32
未找到文件。
src/vs/workbench/parts/git/browser/gitActions.contribution.ts
浏览文件 @
e74a5aa3
...
...
@@ -19,7 +19,7 @@ import filesCommon = require('vs/workbench/parts/files/common/files');
import
gitcontrib
=
require
(
'
vs/workbench/parts/git/browser/gitWorkbenchContributions
'
);
import
{
IGitService
,
Status
,
IFileStatus
,
StatusType
}
from
'
vs/workbench/parts/git/common/git
'
;
import
gitei
=
require
(
'
vs/workbench/parts/git/browser/gitEditorInputs
'
);
import
stageranges
=
require
(
'
vs/workbench/parts/git/common/stageRanges
'
)
;
import
{
getSelectedChanges
,
applyChangesToModel
}
from
'
vs/workbench/parts/git/common/stageRanges
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IViewletService
}
from
'
vs/workbench/services/viewlet/common/viewletService
'
;
import
{
IPartService
,
Parts
}
from
'
vs/workbench/services/part/common/partService
'
;
...
...
@@ -394,11 +394,13 @@ export abstract class BaseStageRangesAction extends baseeditor.EditorInputAction
return
false
;
}
return
stageranges
.
getSelectedChanges
(
changes
,
selections
).
length
>
0
;
return
getSelectedChanges
(
changes
,
selections
).
length
>
0
;
}
protected
getRangesAppliedResult
(
editor
:
editorbrowser
.
IDiffEditor
)
{
return
stageranges
.
stageRanges
(
editor
);
var
selections
=
editor
.
getSelections
();
var
changes
=
getSelectedChanges
(
editor
.
getLineChanges
(),
selections
);
return
applyChangesToModel
(
editor
.
getModel
().
original
,
editor
.
getModel
().
modified
,
changes
);
}
public
run
():
TPromise
<
any
>
{
...
...
@@ -450,7 +452,16 @@ export class UnstageRangesAction extends BaseStageRangesAction {
}
protected
getRangesAppliedResult
(
editor
:
editorbrowser
.
IDiffEditor
)
{
return
stageranges
.
unstageRanges
(
editor
);
const
selections
=
editor
.
getSelections
();
const
changes
=
getSelectedChanges
(
editor
.
getLineChanges
(),
selections
)
.
map
(
c
=>
({
modifiedStartLineNumber
:
c
.
originalStartLineNumber
,
modifiedEndLineNumber
:
c
.
originalEndLineNumber
,
originalStartLineNumber
:
c
.
modifiedStartLineNumber
,
originalEndLineNumber
:
c
.
modifiedEndLineNumber
}));
return
applyChangesToModel
(
editor
.
getModel
().
modified
,
editor
.
getModel
().
original
,
changes
);
}
}
...
...
src/vs/workbench/parts/git/common/stageRanges.ts
浏览文件 @
e74a5aa3
...
...
@@ -4,12 +4,11 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
editorbrowser
=
require
(
'
vs/editor/browser/editorBrowser
'
);
import
editorcommon
=
require
(
'
vs/editor/common/editorCommon
'
);
import
{
IChange
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
function
sortChanges
(
changes
:
editorcommon
.
IChange
[]):
void
{
function
sortChanges
(
changes
:
IChange
[]):
void
{
changes
.
sort
((
left
,
right
)
=>
{
if
(
left
.
originalStartLineNumber
<
right
.
originalStartLineNumber
)
{
return
-
1
;
...
...
@@ -31,42 +30,21 @@ function sortSelections(selections:Selection[]):void {
});
}
function
isInsertion
(
change
:
editorcommon
.
IChange
):
boolean
{
function
isInsertion
(
change
:
IChange
):
boolean
{
return
change
.
originalEndLineNumber
<=
0
;
}
function
isDeletion
(
change
:
editorcommon
.
IChange
):
boolean
{
function
isDeletion
(
change
:
IChange
):
boolean
{
return
change
.
modifiedEndLineNumber
<=
0
;
}
/**
* Returns a new IModel that has all the selected changes from modified IModel applied to the original IModel.
*/
export
function
stageRanges
(
diff
:
editorbrowser
.
IDiffEditor
):
string
{
var
selections
=
diff
.
getSelections
();
var
changes
=
getSelectedChanges
(
diff
.
getLineChanges
(),
selections
);
return
applyChangesToModel
(
diff
.
getModel
().
original
,
diff
.
getModel
().
modified
,
changes
);
}
export
function
unstageRanges
(
diff
:
editorbrowser
.
IDiffEditor
):
string
{
const
selections
=
diff
.
getSelections
();
const
changes
=
getSelectedChanges
(
diff
.
getLineChanges
(),
selections
)
.
map
(
c
=>
({
modifiedStartLineNumber
:
c
.
originalStartLineNumber
,
modifiedEndLineNumber
:
c
.
originalEndLineNumber
,
originalStartLineNumber
:
c
.
modifiedStartLineNumber
,
originalEndLineNumber
:
c
.
modifiedEndLineNumber
}));
return
applyChangesToModel
(
diff
.
getModel
().
modified
,
diff
.
getModel
().
original
,
changes
);
}
/**
* Returns an intersection between a change and a selection.
* Returns null if intersection does not exist.
*/
export
function
intersectChangeAndSelection
(
change
:
editorcommon
.
IChange
,
selection
:
Selection
):
editorcommon
.
IChange
{
var
result
:
editorcommon
.
IChange
=
{
export
function
intersectChangeAndSelection
(
change
:
IChange
,
selection
:
Selection
):
IChange
{
var
result
:
IChange
=
{
modifiedStartLineNumber
:
Math
.
max
(
change
.
modifiedStartLineNumber
,
selection
.
startLineNumber
),
modifiedEndLineNumber
:
Math
.
min
(
change
.
modifiedEndLineNumber
,
selection
.
endLineNumber
),
originalStartLineNumber
:
change
.
originalStartLineNumber
,
...
...
@@ -86,10 +64,10 @@ export function intersectChangeAndSelection(change:editorcommon.IChange, selecti
* Returns all selected changes (there can be multiple selections due to multiple cursors).
* If a change is partially selected, the selected part of the change will be returned.
*/
export
function
getSelectedChanges
(
changes
:
editorcommon
.
IChange
[],
selections
:
Selection
[]):
editorcommon
.
IChange
[]
{
export
function
getSelectedChanges
(
changes
:
IChange
[],
selections
:
Selection
[]):
IChange
[]
{
sortChanges
(
changes
);
sortSelections
(
selections
);
var
result
:
editorcommon
.
IChange
[]
=
[];
var
result
:
IChange
[]
=
[];
var
currentSelection
=
0
;
var
lastLineAdded
=
-
1
;
...
...
@@ -120,7 +98,7 @@ export function getSelectedChanges(changes:editorcommon.IChange[], selections:Se
return
result
;
}
export
function
appendValueFromRange
(
base
:
string
,
model
:
editorcommon
.
IModel
,
range
:
Range
):
string
{
function
appendValueFromRange
(
base
:
string
,
model
:
IModel
,
range
:
Range
):
string
{
var
result
=
base
;
if
(
result
!==
''
)
{
result
+=
model
.
getEOL
();
...
...
@@ -132,7 +110,7 @@ export function appendValueFromRange(base:string, model:editorcommon.IModel, ran
* Applies a list of changes to the original model and returns the new IModel.
* First sorts changes by line number.
*/
export
function
applyChangesToModel
(
original
:
editorcommon
.
IModel
,
modified
:
editorcommon
.
IModel
,
changes
:
editorcommon
.
IChange
[]):
string
{
export
function
applyChangesToModel
(
original
:
IModel
,
modified
:
IModel
,
changes
:
IChange
[]):
string
{
sortChanges
(
changes
);
var
result
=
''
;
var
positionInOriginal
=
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录