Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
940c8d43
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,发现更多精彩内容 >>
提交
940c8d43
编写于
2月 22, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #66
上级
ceae9e0f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
74 addition
and
43 deletion
+74
-43
src/vs/workbench/parts/git/browser/gitEditorContributions.ts
src/vs/workbench/parts/git/browser/gitEditorContributions.ts
+74
-43
未找到文件。
src/vs/workbench/parts/git/browser/gitEditorContributions.ts
浏览文件 @
940c8d43
...
...
@@ -9,9 +9,71 @@ import editorbrowser = require('vs/editor/browser/editorBrowser');
import
common
=
require
(
'
vs/editor/common/editorCommon
'
);
import
git
=
require
(
'
vs/workbench/parts/git/common/git
'
);
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
RunOnceScheduler
}
from
'
vs/base/common/async
'
;
import
IGitService
=
git
.
IGitService
;
class
MergeDecoratorBoundToModel
extends
Disposable
{
private
_editor
:
editorbrowser
.
ICodeEditor
;
private
_model
:
common
.
IModel
;
private
_gitService
:
git
.
IGitService
;
private
_filePath
:
string
;
private
_redecorateSoon
:
RunOnceScheduler
;
private
_decorations
:
string
[];
constructor
(
editor
:
editorbrowser
.
ICodeEditor
,
model
:
common
.
IModel
,
filePath
:
string
,
gitService
:
git
.
IGitService
)
{
super
();
this
.
_editor
=
editor
;
this
.
_model
=
model
;
this
.
_gitService
=
gitService
;
this
.
_filePath
=
filePath
;
this
.
_decorations
=
[];
this
.
_redecorateSoon
=
this
.
_register
(
new
RunOnceScheduler
(()
=>
this
.
redecorate
(),
300
));
this
.
_register
(
this
.
_model
.
addListener2
(
common
.
EventType
.
ModelContentChanged
,
()
=>
this
.
_redecorateSoon
.
schedule
()));
this
.
_register
(
this
.
_gitService
.
addListener2
(
git
.
ServiceEvents
.
STATE_CHANGED
,
()
=>
this
.
_redecorateSoon
.
schedule
()));
this
.
_redecorateSoon
.
schedule
();
}
public
dispose
():
void
{
this
.
_setDecorations
([]);
super
.
dispose
();
}
private
_setDecorations
(
newDecorations
:
common
.
IModelDeltaDecoration
[]):
void
{
this
.
_decorations
=
this
.
_editor
.
deltaDecorations
(
this
.
_decorations
,
newDecorations
);
}
private
redecorate
():
void
{
var
gitModel
=
this
.
_gitService
.
getModel
();
var
mergeStatus
=
gitModel
.
getStatus
().
find
(
this
.
_filePath
,
git
.
StatusType
.
MERGE
);
if
(
!
mergeStatus
)
{
return
;
}
let
decorations
:
common
.
IModelDeltaDecoration
[]
=
[];
let
lineCount
=
this
.
_model
.
getLineCount
();
for
(
let
i
=
1
;
i
<=
lineCount
;
i
++
)
{
let
start
=
this
.
_model
.
getLineContent
(
i
).
substr
(
0
,
7
);
switch
(
start
)
{
case
'
<<<<<<<
'
:
case
'
=======
'
:
case
'
>>>>>>>
'
:
decorations
.
push
({
range
:
{
startLineNumber
:
i
,
startColumn
:
1
,
endLineNumber
:
i
,
endColumn
:
1
},
options
:
MergeDecorator
.
DECORATION_OPTIONS
});
break
;
}
}
this
.
_setDecorations
(
decorations
);
}
}
export
class
MergeDecorator
implements
common
.
IEditorContribution
{
static
ID
=
'
Monaco.IDE.UI.Viewlets.GitViewlet.Editor.MergeDecorator
'
;
...
...
@@ -22,7 +84,8 @@ export class MergeDecorator implements common.IEditorContribution {
color
:
'
rgb(197, 118, 0)
'
,
darkColor
:
'
rgb(197, 118, 0)
'
,
position
:
common
.
OverviewRulerLane
.
Left
}
},
stickiness
:
common
.
TrackedRangeStickiness
.
NeverGrowsWhenTypingAtEdges
};
private
editor
:
editorbrowser
.
ICodeEditor
;
...
...
@@ -30,18 +93,14 @@ export class MergeDecorator implements common.IEditorContribution {
private
contextService
:
IWorkspaceContextService
;
private
toUnbind
:
ee
.
ListenerUnbind
[];
private
decorations
:
string
[];
private
model
:
common
.
IModel
;
private
unbindModelListener
:
()
=>
void
;
private
mergeDecorator
:
MergeDecoratorBoundToModel
;
constructor
(
editor
:
editorbrowser
.
ICodeEditor
,
@
IGitService
gitService
:
IGitService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
)
{
this
.
gitService
=
gitService
;
this
.
contextService
=
contextService
;
this
.
editor
=
editor
;
this
.
toUnbind
=
[
this
.
editor
.
addListener
(
common
.
EventType
.
ModelChanged
,
this
.
onModelChanged
.
bind
(
this
))
];
this
.
decorations
=
[];
this
.
model
=
null
;
this
.
unbindModelListener
=
null
;
this
.
mergeDecorator
=
null
;
}
public
getId
():
string
{
...
...
@@ -49,11 +108,9 @@ export class MergeDecorator implements common.IEditorContribution {
}
private
onModelChanged
():
void
{
if
(
this
.
model
)
{
this
.
decorations
=
this
.
model
.
deltaDecorations
(
this
.
decorations
,
[]);
this
.
unbindModelListener
();
this
.
unbindModelListener
=
null
;
this
.
model
=
null
;
if
(
this
.
mergeDecorator
)
{
this
.
mergeDecorator
.
dispose
();
this
.
mergeDecorator
=
null
;
}
if
(
!
this
.
contextService
||
!
this
.
gitService
)
{
...
...
@@ -75,40 +132,14 @@ export class MergeDecorator implements common.IEditorContribution {
return
;
}
var
gitModel
=
this
.
gitService
.
getModel
();
var
mergeStatus
=
gitModel
.
getStatus
().
find
(
path
,
git
.
StatusType
.
MERGE
);
if
(
!
mergeStatus
)
{
return
;
}
this
.
model
=
model
;
this
.
redecorate
();
this
.
unbindModelListener
=
this
.
model
.
addListener
(
common
.
EventType
.
ModelContentChanged
,
this
.
redecorate
.
bind
(
this
));
}
private
redecorate
():
void
{
var
decorations
:
common
.
IModelDeltaDecoration
[]
=
[];
var
lineCount
=
this
.
model
.
getLineCount
();
for
(
var
i
=
1
;
i
<=
lineCount
;
i
++
)
{
var
start
=
this
.
model
.
getLineContent
(
i
).
substr
(
0
,
7
);
switch
(
start
)
{
case
'
<<<<<<<
'
:
case
'
=======
'
:
case
'
>>>>>>>
'
:
decorations
.
push
({
range
:
{
startLineNumber
:
i
,
startColumn
:
1
,
endLineNumber
:
i
,
endColumn
:
1
},
options
:
MergeDecorator
.
DECORATION_OPTIONS
});
break
;
}
}
this
.
decorations
=
this
.
model
.
deltaDecorations
(
this
.
decorations
,
decorations
);
this
.
mergeDecorator
=
new
MergeDecoratorBoundToModel
(
this
.
editor
,
model
,
path
,
this
.
gitService
);
}
public
dispose
():
void
{
if
(
this
.
mergeDecorator
)
{
this
.
mergeDecorator
.
dispose
();
this
.
mergeDecorator
=
null
;
}
while
(
this
.
toUnbind
.
length
)
{
this
.
toUnbind
.
pop
()();
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录