Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
424812d9
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,发现更多精彩内容 >>
提交
424812d9
编写于
1月 19, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
git: merge decorator
fixes #18663
上级
d0badb14
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
157 addition
and
1 deletion
+157
-1
extensions/git/src/iterators.ts
extensions/git/src/iterators.ts
+57
-0
extensions/git/src/main.ts
extensions/git/src/main.ts
+4
-1
extensions/git/src/merge.ts
extensions/git/src/merge.ts
+96
-0
未找到文件。
extensions/git/src/iterators.ts
0 → 100644
浏览文件 @
424812d9
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
function
*
filter
<
T
>
(
it
:
IterableIterator
<
T
>
,
condition
:
(
t
:
T
,
i
:
number
)
=>
boolean
):
IterableIterator
<
T
>
{
let
i
=
0
;
for
(
let
t
of
it
)
{
if
(
condition
(
t
,
i
++
))
{
yield
t
;
}
}
}
function
*
map
<
T
,
R
>
(
it
:
IterableIterator
<
T
>
,
fn
:
(
t
:
T
,
i
:
number
)
=>
R
):
IterableIterator
<
R
>
{
let
i
=
0
;
for
(
let
t
of
it
)
{
yield
fn
(
t
,
i
++
);
}
}
export
interface
FunctionalIterator
<
T
>
extends
Iterable
<
T
>
{
filter
(
condition
:
(
t
:
T
,
i
:
number
)
=>
boolean
):
FunctionalIterator
<
T
>
;
map
<
R
>
(
fn
:
(
t
:
T
,
i
:
number
)
=>
R
):
FunctionalIterator
<
R
>
;
toArray
():
T
[];
}
class
FunctionalIteratorImpl
<
T
>
implements
FunctionalIterator
<
T
>
{
constructor
(
private
iterator
:
IterableIterator
<
T
>
)
{
}
filter
(
condition
:
(
t
:
T
,
i
:
number
)
=>
boolean
):
FunctionalIterator
<
T
>
{
return
new
FunctionalIteratorImpl
(
filter
(
this
.
iterator
,
condition
));
}
map
<
R
>
(
fn
:
(
t
:
T
,
i
:
number
)
=>
R
):
FunctionalIterator
<
R
>
{
return
new
FunctionalIteratorImpl
(
map
<
T
,
R
>
(
this
.
iterator
,
fn
));
}
toArray
():
T
[]
{
return
Array
.
from
(
this
.
iterator
);
}
[
Symbol
.
iterator
]():
IterableIterator
<
T
>
{
return
this
.
iterator
;
}
}
export
function
iterate
<
T
>
(
obj
:
T
[]
|
IterableIterator
<
T
>
):
FunctionalIterator
<
T
>
{
if
(
Array
.
isArray
(
obj
))
{
return
new
FunctionalIteratorImpl
(
obj
[
Symbol
.
iterator
]());
}
return
new
FunctionalIteratorImpl
(
obj
);
}
\ No newline at end of file
extensions/git/src/main.ts
浏览文件 @
424812d9
...
@@ -14,6 +14,7 @@ import { CheckoutStatusBar, SyncStatusBar } from './statusbar';
...
@@ -14,6 +14,7 @@ import { CheckoutStatusBar, SyncStatusBar } from './statusbar';
import
{
filterEvent
,
anyEvent
}
from
'
./util
'
;
import
{
filterEvent
,
anyEvent
}
from
'
./util
'
;
import
{
GitContentProvider
}
from
'
./contentProvider
'
;
import
{
GitContentProvider
}
from
'
./contentProvider
'
;
import
{
AutoFetcher
}
from
'
./autofetch
'
;
import
{
AutoFetcher
}
from
'
./autofetch
'
;
import
{
MergeDecorator
}
from
'
./merge
'
;
import
*
as
nls
from
'
vscode-nls
'
;
import
*
as
nls
from
'
vscode-nls
'
;
const
localize
=
nls
.
config
()();
const
localize
=
nls
.
config
()();
...
@@ -46,6 +47,7 @@ async function init(disposables: Disposable[]): Promise<void> {
...
@@ -46,6 +47,7 @@ async function init(disposables: Disposable[]): Promise<void> {
const
checkoutStatusBar
=
new
CheckoutStatusBar
(
model
);
const
checkoutStatusBar
=
new
CheckoutStatusBar
(
model
);
const
syncStatusBar
=
new
SyncStatusBar
(
model
);
const
syncStatusBar
=
new
SyncStatusBar
(
model
);
const
autoFetcher
=
new
AutoFetcher
(
model
);
const
autoFetcher
=
new
AutoFetcher
(
model
);
const
mergeDecorator
=
new
MergeDecorator
(
model
);
disposables
.
push
(
disposables
.
push
(
commandCenter
,
commandCenter
,
...
@@ -55,7 +57,8 @@ async function init(disposables: Disposable[]): Promise<void> {
...
@@ -55,7 +57,8 @@ async function init(disposables: Disposable[]): Promise<void> {
fsWatcher
,
fsWatcher
,
checkoutStatusBar
,
checkoutStatusBar
,
syncStatusBar
,
syncStatusBar
,
autoFetcher
autoFetcher
,
mergeDecorator
);
);
}
}
...
...
extensions/git/src/merge.ts
0 → 100644
浏览文件 @
424812d9
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
window
,
workspace
,
Disposable
,
TextEditor
,
TextDocument
,
Range
}
from
'
vscode
'
;
import
{
Model
,
Status
}
from
'
./model
'
;
import
{
filterEvent
}
from
'
./util
'
;
import
{
debounce
}
from
'
./decorators
'
;
import
{
iterate
}
from
'
./iterators
'
;
function
*
lines
(
document
:
TextDocument
):
IterableIterator
<
string
>
{
for
(
let
i
=
0
;
i
<
document
.
lineCount
;
i
++
)
{
yield
document
.
lineAt
(
i
).
text
;
}
}
const
pattern
=
/^<<<<<<<|^=======|^>>>>>>>/
;
function
decorate
(
document
:
TextDocument
):
Range
[]
{
return
iterate
(
lines
(
document
))
.
map
((
line
,
i
)
=>
pattern
.
test
(
line
)
?
i
:
null
)
.
filter
(
i
=>
i
!==
null
)
.
map
((
i
:
number
)
=>
new
Range
(
i
,
1
,
i
,
1
))
.
toArray
();
}
class
TextEditorMergeDecorator
{
private
static
DecorationType
=
window
.
createTextEditorDecorationType
({
backgroundColor
:
'
rgba(255, 139, 0, 0.3)
'
,
isWholeLine
:
true
,
dark
:
{
backgroundColor
:
'
rgba(235, 59, 0, 0.3)
'
}
});
private
uri
:
string
;
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
model
:
Model
,
private
editor
:
TextEditor
)
{
this
.
uri
=
this
.
editor
.
document
.
uri
.
toString
();
const
onDidChange
=
filterEvent
(
workspace
.
onDidChangeTextDocument
,
e
=>
e
.
document
&&
e
.
document
.
uri
.
toString
()
===
this
.
uri
);
onDidChange
(
this
.
redecorate
,
this
,
this
.
disposables
);
model
.
onDidChange
(
this
.
redecorate
,
this
,
this
.
disposables
);
this
.
redecorate
();
}
@
debounce
(
300
)
private
redecorate
():
void
{
let
decorations
:
Range
[]
=
[];
if
(
window
.
visibleTextEditors
.
every
(
e
=>
e
!==
this
.
editor
))
{
this
.
dispose
();
return
;
}
if
(
this
.
model
.
mergeGroup
.
resources
.
some
(
r
=>
r
.
type
===
Status
.
BOTH_MODIFIED
&&
r
.
uri
.
toString
()
===
this
.
uri
))
{
decorations
=
decorate
(
this
.
editor
.
document
);
}
this
.
editor
.
setDecorations
(
TextEditorMergeDecorator
.
DecorationType
,
decorations
);
}
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
}
}
export
class
MergeDecorator
{
private
textEditorDecorators
:
TextEditorMergeDecorator
[]
=
[];
private
disposables
:
Disposable
[]
=
[];
constructor
(
private
model
:
Model
)
{
window
.
onDidChangeVisibleTextEditors
(
this
.
onDidChangeVisibleTextEditors
,
this
,
this
.
disposables
);
this
.
onDidChangeVisibleTextEditors
(
window
.
visibleTextEditors
);
}
private
onDidChangeVisibleTextEditors
(
editors
:
TextEditor
[]):
void
{
this
.
textEditorDecorators
.
forEach
(
d
=>
d
.
dispose
());
this
.
textEditorDecorators
=
editors
.
map
(
e
=>
new
TextEditorMergeDecorator
(
this
.
model
,
e
));
}
dispose
():
void
{
this
.
textEditorDecorators
.
forEach
(
d
=>
d
.
dispose
());
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录