Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e17815a8
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,发现更多精彩内容 >>
提交
e17815a8
编写于
3月 12, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set selection for cell
上级
c6c03851
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
60 addition
and
9 deletion
+60
-9
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts
...bench/contrib/codeEditor/browser/find/simpleFindWidget.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/contrib/notebookFindWidget.ts
...ch/contrib/notebook/browser/contrib/notebookFindWidget.ts
+29
-6
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+2
-0
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+8
-0
src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts
...rkbench/contrib/notebook/browser/view/notebookCellList.ts
+12
-2
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
...ntrib/notebook/browser/viewModel/notebookCellViewModel.ts
+8
-0
未找到文件。
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindWidget.ts
浏览文件 @
e17815a8
...
...
@@ -26,7 +26,7 @@ const NLS_NEXT_MATCH_BTN_LABEL = nls.localize('label.nextMatchButton', "Next mat
const
NLS_CLOSE_BTN_LABEL
=
nls
.
localize
(
'
label.closeButton
'
,
"
Close
"
);
export
abstract
class
SimpleFindWidget
extends
Widget
{
pr
ivate
readonly
_findInput
:
FindInput
;
pr
otected
readonly
_findInput
:
FindInput
;
private
readonly
_domNode
:
HTMLElement
;
private
readonly
_innerDomNode
:
HTMLElement
;
private
readonly
_focusTracker
:
dom
.
IFocusTracker
;
...
...
src/vs/workbench/contrib/notebook/browser/contrib/notebookFindWidget.ts
浏览文件 @
e17815a8
...
...
@@ -12,6 +12,8 @@ import { ModelDecorationOptions } from 'vs/editor/common/model/textModel';
import
{
IModelDeltaDecoration
}
from
'
vs/editor/common/model
'
;
import
{
ICellModelDeltaDecorations
,
ICellModelDecorations
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
import
{
KeyCode
}
from
'
vs/base/common/keyCodes
'
;
export
class
NotebookFindWidget
extends
SimpleFindWidget
{
protected
_findWidgetFocused
:
IContextKey
<
boolean
>
;
...
...
@@ -28,22 +30,42 @@ export class NotebookFindWidget extends SimpleFindWidget {
)
{
super
(
contextViewService
,
contextKeyService
);
this
.
_findWidgetFocused
=
KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED
.
bindTo
(
contextKeyService
);
this
.
_register
(
this
.
_findInput
.
onKeyDown
((
e
)
=>
this
.
_onFindInputKeyDown
(
e
)));
}
private
_onFindInputKeyDown
(
e
:
IKeyboardEvent
):
void
{
if
(
e
.
equals
(
KeyCode
.
Enter
))
{
if
(
this
.
_findMatches
.
length
)
{
this
.
set
(
this
.
_findMatches
);
if
(
this
.
_currentMatch
!==
-
1
)
{
const
nextIndex
=
this
.
_findMatchesStarts
!
.
getIndexOf
(
this
.
_currentMatch
);
const
cellIndex
=
nextIndex
.
index
;
const
matchIndex
=
nextIndex
.
remainder
;
this
.
_findMatches
[
cellIndex
].
cell
.
isEditing
=
true
;
this
.
_notebookEditor
.
setSelection
(
this
.
_findMatches
[
cellIndex
].
cell
,
this
.
_findMatches
[
cellIndex
].
matches
[
matchIndex
].
range
);
this
.
_notebookEditor
.
revealRangeInCenterIfOutsideViewport
(
this
.
_findMatches
[
cellIndex
].
cell
,
this
.
_findMatches
[
cellIndex
].
matches
[
matchIndex
].
range
);
}
}
else
{
this
.
set
(
null
);
}
e
.
preventDefault
();
return
;
}
}
protected
onInputChanged
():
boolean
{
const
val
=
this
.
inputValue
;
if
(
val
)
{
const
newMatches
=
this
.
_notebookEditor
.
viewModel
!
.
find
(
val
).
filter
(
match
=>
match
.
matches
.
length
>
0
);
if
(
newMatches
.
length
)
{
this
.
set
(
newMatches
);
this
.
_findMatches
=
this
.
_notebookEditor
.
viewModel
!
.
find
(
val
).
filter
(
match
=>
match
.
matches
.
length
>
0
);
if
(
this
.
_findMatches
.
length
)
{
return
true
;
}
else
{
this
.
set
(
null
);
return
false
;
}
}
else
{
this
.
set
([]);
}
return
false
;
}
...
...
@@ -62,6 +84,7 @@ export class NotebookFindWidget extends SimpleFindWidget {
this
.
setCurrentFindMatchDecoration
(
cellIndex
,
matchIndex
);
this
.
_findMatches
[
cellIndex
].
cell
.
isEditing
=
true
;
this
.
_notebookEditor
.
setSelection
(
this
.
_findMatches
[
cellIndex
].
cell
,
this
.
_findMatches
[
cellIndex
].
matches
[
matchIndex
].
range
);
this
.
_notebookEditor
.
revealRangeInCenterIfOutsideViewport
(
this
.
_findMatches
[
cellIndex
].
cell
,
this
.
_findMatches
[
cellIndex
].
matches
[
matchIndex
].
range
);
}
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
e17815a8
...
...
@@ -141,6 +141,8 @@ export interface INotebookEditor {
*/
revealRangeInCenterIfOutsideViewport
(
cell
:
CellViewModel
,
range
:
Range
):
void
;
setSelection
(
cell
:
CellViewModel
,
selection
:
Range
):
void
;
/**
* Change the decorations on cells.
* The notebook is virtualized and this method should be called to create/delete editor decorations safely.
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
e17815a8
...
...
@@ -483,6 +483,14 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}
}
setSelection
(
cell
:
CellViewModel
,
range
:
Range
):
void
{
const
index
=
this
.
notebookViewModel
?.
getViewCellIndex
(
cell
);
if
(
index
!==
undefined
)
{
this
.
list
?.
setCellSelection
(
index
,
range
);
}
}
changeDecorations
(
callback
:
(
changeAccessor
:
IModelDecorationsChangeAccessor
)
=>
any
):
any
{
return
this
.
notebookViewModel
?.
changeDecorations
(
callback
);
}
...
...
src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts
浏览文件 @
e17815a8
...
...
@@ -209,10 +209,15 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> {
if
(
!
element
.
editorAttached
)
{
getEditorAttachedPromise
(
element
).
then
(()
=>
reveal
(
index
,
range
,
revealType
));
}
else
{
//
should not happe
n
//
for example markdow
n
}
}
else
{
element
.
revealRangeInCenter
(
range
);
if
(
element
.
editorAttached
)
{
element
.
revealRangeInCenter
(
range
);
}
else
{
// for example, markdown cell in preview mode
getEditorAttachedPromise
(
element
).
then
(()
=>
reveal
(
index
,
range
,
revealType
));
}
}
}
...
...
@@ -257,6 +262,11 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> {
this
.
_revealInternal
(
index
,
true
,
CellRevealPosition
.
Center
);
}
setCellSelection
(
index
:
number
,
range
:
Range
)
{
const
element
=
this
.
view
.
element
(
index
);
element
.
setSelection
(
range
);
}
}
function
getEditorAttachedPromise
(
element
:
CellViewModel
)
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
浏览文件 @
e17815a8
...
...
@@ -255,6 +255,10 @@ export class CellViewModel extends Disposable {
}
attachTextEditor
(
editor
:
ICodeEditor
)
{
if
(
this
.
_textEditor
===
editor
)
{
return
;
}
this
.
_textEditor
=
editor
;
if
(
this
.
_editorViewStates
)
{
...
...
@@ -295,6 +299,10 @@ export class CellViewModel extends Disposable {
this
.
_textEditor
?.
revealRangeInCenter
(
range
);
}
setSelection
(
range
:
Range
)
{
this
.
_textEditor
?.
setSelection
(
range
);
}
getLineScrollTopOffset
(
line
:
number
):
number
{
if
(
!
this
.
_textEditor
)
{
return
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录