Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
379b3204
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,发现更多精彩内容 >>
提交
379b3204
编写于
3月 12, 2018
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
first cut of #14783
上级
ee02bc3d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
117 addition
and
40 deletion
+117
-40
src/vs/editor/contrib/gotoError/gotoError.ts
src/vs/editor/contrib/gotoError/gotoError.ts
+117
-40
未找到文件。
src/vs/editor/contrib/gotoError/gotoError.ts
浏览文件 @
379b3204
...
...
@@ -17,12 +17,16 @@ import { Position } from 'vs/editor/common/core/position';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
registerEditorAction
,
registerEditorContribution
,
ServicesAccessor
,
IActionOptions
,
EditorAction
,
EditorCommand
,
registerEditorCommand
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
,
isCodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
}
from
'
vs/platform/theme/common/colorRegistry
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
MarkerNavigationWidget
}
from
'
./gotoErrorWidget
'
;
import
{
compare
}
from
'
vs/base/common/strings
'
;
import
{
binarySearch
}
from
'
vs/base/common/arrays
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
class
MarkerModel
{
...
...
@@ -47,9 +51,13 @@ class MarkerModel {
// listen on editor
this
.
_toUnbind
.
push
(
this
.
_editor
.
onDidDispose
(()
=>
this
.
dispose
()));
this
.
_toUnbind
.
push
(
this
.
_editor
.
onDidChangeCursorPosition
(()
=>
{
if
(
!
this
.
_ignoreSelectionChange
)
{
this
.
_nextIdx
=
-
1
;
if
(
this
.
_ignoreSelectionChange
)
{
return
;
}
if
(
this
.
currentMarker
&&
Range
.
containsPosition
(
this
.
currentMarker
,
this
.
_editor
.
getPosition
()))
{
return
;
}
this
.
_nextIdx
=
-
1
;
}));
}
...
...
@@ -62,13 +70,15 @@ class MarkerModel {
}
public
setMarkers
(
markers
:
IMarker
[]):
void
{
// assign
this
.
_markers
=
markers
||
[];
// sort markers
this
.
_markers
.
sort
((
left
,
right
)
=>
Severity
.
compare
(
left
.
severity
,
right
.
severity
)
||
Range
.
compareRangesUsingStarts
(
left
,
right
));
this
.
_nextIdx
=
-
1
;
let
oldMarker
=
this
.
_nextIdx
>=
0
?
this
.
_markers
[
this
.
_nextIdx
]
:
undefined
;
this
.
_markers
=
markers
||
[];
this
.
_markers
.
sort
(
MarkerNavigationAction
.
compareMarker
);
if
(
!
oldMarker
)
{
this
.
_nextIdx
=
-
1
;
}
else
{
this
.
_nextIdx
=
Math
.
max
(
-
1
,
binarySearch
(
this
.
_markers
,
oldMarker
,
MarkerNavigationAction
.
compareMarker
));
}
this
.
_onMarkerSetChanged
.
fire
(
this
);
}
...
...
@@ -95,7 +105,7 @@ class MarkerModel {
}
if
(
range
.
containsPosition
(
position
)
||
position
.
isBeforeOrEqual
(
range
.
getStartPosition
()))
{
this
.
_nextIdx
=
i
+
(
fwd
?
0
:
-
1
)
;
this
.
_nextIdx
=
i
;
found
=
true
;
break
;
}
...
...
@@ -109,29 +119,43 @@ class MarkerModel {
}
}
public
move
(
fwd
:
boolean
,
circle
:
boolean
):
boolean
{
get
currentMarker
():
IMarker
{
return
this
.
canNavigate
()
?
this
.
_markers
[
this
.
_nextIdx
]
:
undefined
;
}
public
move
(
fwd
:
boolean
,
inCircles
:
boolean
):
boolean
{
if
(
!
this
.
canNavigate
())
{
this
.
_onCurrentMarkerChanged
.
fire
(
undefined
);
return
false
;
return
!
inCircles
;
}
let
old
=
this
.
_nextIdx
;
let
oldIdx
=
this
.
_nextIdx
;
let
atEdge
=
false
;
if
(
this
.
_nextIdx
===
-
1
)
{
this
.
_initIdx
(
fwd
);
}
else
if
(
fwd
)
{
this
.
_nextIdx
=
(
this
.
_nextIdx
+
1
)
%
this
.
_markers
.
length
;
}
else
{
this
.
_nextIdx
=
(
this
.
_nextIdx
-
1
+
this
.
_markers
.
length
)
%
this
.
_markers
.
length
;
if
(
inCircles
||
this
.
_nextIdx
+
1
<
this
.
_markers
.
length
)
{
this
.
_nextIdx
=
(
this
.
_nextIdx
+
1
)
%
this
.
_markers
.
length
;
}
else
{
atEdge
=
true
;
}
}
else
if
(
!
fwd
)
{
if
(
inCircles
||
this
.
_nextIdx
>
0
)
{
this
.
_nextIdx
=
(
this
.
_nextIdx
-
1
+
this
.
_markers
.
length
)
%
this
.
_markers
.
length
;
}
else
{
atEdge
=
true
;
}
}
if
(
circle
||
old
===
-
1
||
fwd
&&
old
<
this
.
_nextIdx
||
!
fwd
&&
old
>
this
.
_nextIdx
)
{
if
(
oldIdx
!==
this
.
_nextIdx
)
{
const
marker
=
this
.
_markers
[
this
.
_nextIdx
];
this
.
_onCurrentMarkerChanged
.
fire
(
marker
);
return
false
;
}
// we circled, didn't send an event, and return `true`
return
true
;
return
atEdge
;
}
public
canNavigate
():
boolean
{
...
...
@@ -160,26 +184,6 @@ class MarkerModel {
}
}
class
MarkerNavigationAction
extends
EditorAction
{
private
_isNext
:
boolean
;
constructor
(
next
:
boolean
,
opts
:
IActionOptions
)
{
super
(
opts
);
this
.
_isNext
=
next
;
}
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
void
{
const
controller
=
MarkerController
.
get
(
editor
);
if
(
!
controller
)
{
return
;
}
const
model
=
controller
.
getOrCreateModel
();
model
.
move
(
this
.
_isNext
,
true
);
}
}
class
MarkerController
implements
editorCommon
.
IEditorContribution
{
private
static
readonly
ID
=
'
editor.contrib.markerController
'
;
...
...
@@ -274,6 +278,79 @@ class MarkerController implements editorCommon.IEditorContribution {
}
}
class
MarkerNavigationAction
extends
EditorAction
{
private
_isNext
:
boolean
;
constructor
(
next
:
boolean
,
opts
:
IActionOptions
)
{
super
(
opts
);
this
.
_isNext
=
next
;
}
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
TPromise
<
void
>
{
const
markerService
=
accessor
.
get
(
IMarkerService
);
const
editorService
=
accessor
.
get
(
IEditorService
);
const
controller
=
MarkerController
.
get
(
editor
);
if
(
!
controller
)
{
return
undefined
;
}
const
model
=
controller
.
getOrCreateModel
();
const
atEdge
=
model
.
move
(
this
.
_isNext
,
false
);
if
(
!
atEdge
)
{
return
undefined
;
}
// try with the next/prev file
let
oldMarker
=
model
.
currentMarker
||
{
resource
:
editor
.
getModel
().
uri
,
severity
:
Severity
.
Error
,
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
1
,
endColumn
:
1
};
let
markers
=
markerService
.
read
().
sort
(
MarkerNavigationAction
.
compareMarker
);
let
idx
=
binarySearch
(
markers
,
oldMarker
,
MarkerNavigationAction
.
compareMarker
);
if
(
idx
<
0
)
{
// find best match...
idx
=
~
idx
;
idx
%=
markers
.
length
;
}
else
if
(
this
.
_isNext
)
{
idx
=
(
idx
+
1
)
%
markers
.
length
;
}
else
{
idx
=
(
idx
+
markers
.
length
-
1
)
%
markers
.
length
;
}
let
newMarker
=
markers
[
idx
];
if
(
newMarker
.
resource
.
toString
()
===
editor
.
getModel
().
uri
.
toString
())
{
// the next `resource` is this resource which
// means we cycle within this file
model
.
move
(
this
.
_isNext
,
true
);
return
undefined
;
}
// close the widget for this editor-instance, open the resource
// for the next marker and re-start marker navigation in there
controller
.
closeMarkersNavigation
();
return
editorService
.
openEditor
({
resource
:
newMarker
.
resource
,
options
:
{
pinned
:
false
,
revealIfOpened
:
true
,
revealInCenterIfOutsideViewport
:
true
,
selection
:
newMarker
}
}).
then
(
editor
=>
{
if
(
!
editor
||
!
isCodeEditor
(
editor
.
getControl
()))
{
return
undefined
;
}
return
(
<
ICodeEditor
>
editor
.
getControl
()).
getAction
(
this
.
id
).
run
();
});
}
static
compareMarker
(
a
:
IMarker
,
b
:
IMarker
):
number
{
let
res
=
compare
(
a
.
resource
.
toString
(),
b
.
resource
.
toString
());
if
(
res
===
0
)
{
res
=
Severity
.
compare
(
a
.
severity
,
b
.
severity
);
}
if
(
res
===
0
)
{
res
=
Range
.
compareRangesUsingStarts
(
a
,
b
);
}
return
res
;
}
}
class
NextMarkerAction
extends
MarkerNavigationAction
{
constructor
()
{
super
(
true
,
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录