Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c0508af4
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,发现更多精彩内容 >>
提交
c0508af4
编写于
4月 19, 2018
作者:
P
Peng Lyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
dispose comment provider when switching between branches
上级
55198cb5
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
93 addition
and
12 deletion
+93
-12
extensions/git-extended/src/common/models/repository.ts
extensions/git-extended/src/common/models/repository.ts
+21
-1
extensions/git-extended/src/common/util.ts
extensions/git-extended/src/common/util.ts
+58
-1
extensions/git-extended/src/review/reviewMode.ts
extensions/git-extended/src/review/reviewMode.ts
+14
-5
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+0
-5
未找到文件。
extensions/git-extended/src/common/models/repository.ts
浏览文件 @
c0508af4
...
...
@@ -6,7 +6,7 @@
import
*
as
vscode
from
'
vscode
'
;
import
{
Remote
}
from
'
./remote
'
;
import
{
GitProcess
}
from
'
dugite
'
;
import
{
uniqBy
}
from
'
../util
'
;
import
{
uniqBy
,
anyEvent
,
filterEvent
,
isDescendant
}
from
'
../util
'
;
import
{
parseRemote
}
from
'
../remote
'
;
import
{
CredentialStore
}
from
'
../../credentials
'
;
import
{
PullRequest
,
PRType
}
from
'
./pullrequest
'
;
...
...
@@ -58,9 +58,29 @@ export class Repository {
return
this
.
_remotes
;
}
private
statusTimeout
:
any
;
private
disposables
:
vscode
.
Disposable
[]
=
[];
constructor
(
path
:
string
,
workspaceState
:
vscode
.
Memento
)
{
this
.
path
=
path
;
const
fsWatcher
=
vscode
.
workspace
.
createFileSystemWatcher
(
'
**
'
);
this
.
disposables
.
push
(
fsWatcher
);
const
onWorkspaceChange
=
anyEvent
(
fsWatcher
.
onDidChange
,
fsWatcher
.
onDidCreate
,
fsWatcher
.
onDidDelete
);
const
onRepositoryChange
=
filterEvent
(
onWorkspaceChange
,
uri
=>
isDescendant
(
this
.
path
,
uri
.
fsPath
));
const
onRelevantRepositoryChange
=
filterEvent
(
onRepositoryChange
,
uri
=>
!
/
\/\.
git
(\/
index
\.
lock
)?
$/
.
test
(
uri
.
path
));
onRelevantRepositoryChange
(
this
.
onFSChange
,
this
,
this
.
disposables
);
this
.
status
();
}
onFSChange
()
{
clearTimeout
(
this
.
statusTimeout
);
this
.
statusTimeout
=
setTimeout
(()
=>
{
this
.
status
();
},
1000
);
}
async
status
()
{
...
...
extensions/git-extended/src/common/util.ts
浏览文件 @
c0508af4
...
...
@@ -4,6 +4,8 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Event
}
from
'
vscode
'
;
import
{
sep
}
from
'
path
'
;
export
function
uniqBy
<
T
>
(
arr
:
T
[],
fn
:
(
el
:
T
)
=>
string
):
T
[]
{
const
seen
=
Object
.
create
(
null
);
...
...
@@ -19,3 +21,58 @@ export function uniqBy<T>(arr: T[], fn: (el: T) => string): T[] {
return
true
;
});
}
export
interface
IDisposable
{
dispose
():
void
;
}
export
function
dispose
<
T
extends
IDisposable
>
(
disposables
:
T
[]):
T
[]
{
disposables
.
forEach
(
d
=>
d
.
dispose
());
return
[];
}
export
function
toDisposable
(
dispose
:
()
=>
void
):
IDisposable
{
return
{
dispose
};
}
export
function
combinedDisposable
(
disposables
:
IDisposable
[]):
IDisposable
{
return
toDisposable
(()
=>
dispose
(
disposables
));
}
export
function
anyEvent
<
T
>
(...
events
:
Event
<
T
>
[]):
Event
<
T
>
{
return
(
listener
,
thisArgs
=
null
,
disposables
?)
=>
{
const
result
=
combinedDisposable
(
events
.
map
(
event
=>
event
(
i
=>
listener
.
call
(
thisArgs
,
i
))));
if
(
disposables
)
{
disposables
.
push
(
result
);
}
return
result
;
};
}
export
function
filterEvent
<
T
>
(
event
:
Event
<
T
>
,
filter
:
(
e
:
T
)
=>
boolean
):
Event
<
T
>
{
return
(
listener
,
thisArgs
=
null
,
disposables
?)
=>
event
(
e
=>
filter
(
e
)
&&
listener
.
call
(
thisArgs
,
e
),
null
,
disposables
);
}
function
isWindowsPath
(
path
:
string
):
boolean
{
return
/^
[
a-zA-Z
]
:
\\
/
.
test
(
path
);
}
export
function
isDescendant
(
parent
:
string
,
descendant
:
string
):
boolean
{
if
(
parent
===
descendant
)
{
return
true
;
}
if
(
parent
.
charAt
(
parent
.
length
-
1
)
!==
sep
)
{
parent
+=
sep
;
}
// Windows is case insensitive
if
(
isWindowsPath
(
parent
))
{
parent
=
parent
.
toLowerCase
();
descendant
=
descendant
.
toLowerCase
();
}
return
descendant
.
startsWith
(
parent
);
}
extensions/git-extended/src/review/reviewMode.ts
浏览文件 @
c0508af4
...
...
@@ -23,8 +23,6 @@ export interface ReviewState {
branch
:
string
;
head
:
any
;
base
:
any
;
fileChanges
:
any
;
comments
:
any
;
}
export
class
ReviewMode
{
...
...
@@ -60,7 +58,6 @@ export class ReviewMode {
}));
this
.
validateState
();
this
.
pollForStatusChange
();
}
...
...
@@ -93,7 +90,12 @@ export class ReviewMode {
}
this
.
_prNumber
=
state
.
prNumber
;
if
(
!
state
.
head
||
!
state
.
base
)
{
// load pr
this
.
_lastCommitSha
=
null
;
}
else
{
this
.
_lastCommitSha
=
state
[
'
head
'
].
sha
;
}
// we switch to another PR, let's clean up first.
this
.
clear
();
...
...
@@ -104,6 +106,13 @@ export class ReviewMode {
}
const
pr
=
await
githubRepo
.
getPullRequest
(
this
.
_prNumber
);
state
.
base
=
pr
.
prItem
.
base
;
state
.
head
=
pr
.
prItem
.
head
;
this
.
_workspaceState
.
update
(
`
${
REVIEW_STATE
}
:
${
branch
}
`
,
state
);
if
(
!
this
.
_lastCommitSha
)
{
this
.
_lastCommitSha
=
state
.
head
.
sha
;
}
await
this
.
getPullRequestData
(
pr
);
let
prChangeResources
=
this
.
_localFileChanges
.
map
(
fileChange
=>
({
...
...
@@ -288,7 +297,7 @@ export class ReviewMode {
}
registerCommentProvider
()
{
vscode
.
workspace
.
registerCommentProvider
({
this
.
_commentProvider
=
vscode
.
workspace
.
registerCommentProvider
({
onDidChangeCommentThreads
:
this
.
_onDidChangeCommentThreads
.
event
,
provideComments
:
async
(
document
:
vscode
.
TextDocument
,
token
:
vscode
.
CancellationToken
)
=>
{
let
lastLine
=
document
.
lineCount
;
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
c0508af4
...
...
@@ -784,11 +784,6 @@ declare module 'vscode' {
reply
?:
Command
;
}
interface
NewCommentAction
{
ranges
:
Range
[];
actions
?:
Command
[];
}
interface
Comment
{
commentId
:
string
;
body
:
MarkdownString
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录