Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
cc97d374
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,发现更多精彩内容 >>
提交
cc97d374
编写于
3月 22, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
✨
multi-select (un)stage & discard git commands
上级
0c863e6c
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
47 addition
and
15 deletion
+47
-15
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+24
-15
extensions/git/src/util.ts
extensions/git/src/util.ts
+15
-0
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+8
-0
未找到文件。
extensions/git/src/commands.ts
浏览文件 @
cc97d374
...
...
@@ -11,6 +11,7 @@ import { Model, Resource, Status, CommitOptions } from './model';
import
*
as
staging
from
'
./staging
'
;
import
*
as
path
from
'
path
'
;
import
*
as
os
from
'
os
'
;
import
{
uniqueFilter
}
from
'
./util
'
;
import
TelemetryReporter
from
'
vscode-extension-telemetry
'
;
import
*
as
nls
from
'
vscode-nls
'
;
...
...
@@ -272,14 +273,14 @@ export class CommandCenter {
}
@
command
(
'
git.stage
'
)
async
stage
(
uri
?:
Uri
):
Promise
<
void
>
{
const
resource
=
this
.
resolveSCMResource
(
uri
);
async
stage
(
...
uris
:
Uri
[]
):
Promise
<
void
>
{
const
resource
s
=
this
.
toSCMResources
(
uris
);
if
(
!
resource
)
{
if
(
!
resource
s
.
length
)
{
return
;
}
return
await
this
.
model
.
add
(
resource
);
return
await
this
.
model
.
add
(
...
resources
);
}
@
command
(
'
git.stageAll
'
)
...
...
@@ -369,14 +370,14 @@ export class CommandCenter {
}
@
command
(
'
git.unstage
'
)
async
unstage
(
uri
?:
Uri
):
Promise
<
void
>
{
const
resource
=
this
.
resolveSCMResource
(
uri
);
async
unstage
(
...
uris
:
Uri
[]
):
Promise
<
void
>
{
const
resource
s
=
this
.
toSCMResources
(
uris
);
if
(
!
resource
)
{
if
(
!
resource
s
.
length
)
{
return
;
}
return
await
this
.
model
.
revertFiles
(
resource
);
return
await
this
.
model
.
revertFiles
(
...
resources
);
}
@
command
(
'
git.unstageAll
'
)
...
...
@@ -427,15 +428,17 @@ export class CommandCenter {
}
@
command
(
'
git.clean
'
)
async
clean
(
uri
?:
Uri
):
Promise
<
void
>
{
const
resource
=
this
.
resolveSCMResource
(
uri
);
async
clean
(
...
uris
:
Uri
[]
):
Promise
<
void
>
{
const
resource
s
=
this
.
toSCMResources
(
uris
);
if
(
!
resource
)
{
if
(
!
resource
s
.
length
)
{
return
;
}
const
basename
=
path
.
basename
(
resource
.
uri
.
fsPath
);
const
message
=
localize
(
'
confirm discard
'
,
"
Are you sure you want to discard changes in {0}?
"
,
basename
);
const
message
=
resources
.
length
===
1
?
localize
(
'
confirm discard
'
,
"
Are you sure you want to discard changes in {0}?
"
,
path
.
basename
(
resources
[
0
].
uri
.
fsPath
))
:
localize
(
'
confirm discard multiple
'
,
"
Are you sure you want to discard changes in {0} files?
"
,
resources
.
length
);
const
yes
=
localize
(
'
discard
'
,
"
Discard Changes
"
);
const
pick
=
await
window
.
showWarningMessage
(
message
,
{
modal
:
true
},
yes
);
...
...
@@ -443,7 +446,7 @@ export class CommandCenter {
return
;
}
await
this
.
model
.
clean
(
resource
);
await
this
.
model
.
clean
(
...
resources
);
}
@
command
(
'
git.cleanAll
'
)
...
...
@@ -773,7 +776,7 @@ export class CommandCenter {
uri
=
uri
||
window
.
activeTextEditor
&&
window
.
activeTextEditor
.
document
.
uri
;
if
(
!
uri
)
{
return
;
return
undefined
;
}
if
(
uri
.
scheme
===
'
scm
'
&&
uri
.
authority
===
'
git
'
)
{
...
...
@@ -793,6 +796,12 @@ export class CommandCenter {
}
}
private
toSCMResources
(
uris
:
Uri
[]):
Resource
[]
{
return
uris
.
filter
(
uniqueFilter
(
uri
=>
uri
.
toString
()))
.
map
(
uri
=>
this
.
resolveSCMResource
(
uri
))
.
filter
(
r
=>
!!
r
)
as
Resource
[];
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
}
...
...
extensions/git/src/util.ts
浏览文件 @
cc97d374
...
...
@@ -148,3 +148,18 @@ export async function mkdirp(path: string, mode?: number): Promise<boolean> {
return
true
;
}
export
function
uniqueFilter
<
T
>
(
keyFn
:
(
t
:
T
)
=>
string
):
(
t
:
T
)
=>
boolean
{
const
seen
:
{
[
key
:
string
]:
boolean
;
}
=
Object
.
create
(
null
);
return
element
=>
{
const
key
=
keyFn
(
element
);
if
(
seen
[
key
])
{
return
false
;
}
seen
[
key
]
=
true
;
return
true
;
};
}
\ No newline at end of file
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
cc97d374
...
...
@@ -105,6 +105,14 @@ class MultipleSelectionActionRunner extends ActionRunner {
super
();
}
/**
* Calls the action.run method with the current selection. Note
* that these actions already have the current scm resource context
* within, so we don't want to pass in the selection if there is only
* one selected element. The user should be able to select a single
* item and run an action on another element and only the latter should
* be influenced.
*/
runAction
(
action
:
IAction
,
context
?:
any
):
TPromise
<
any
>
{
if
(
action
instanceof
MenuItemAction
)
{
const
selection
=
this
.
getSelectedResources
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录