Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
dab68ed8
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,发现更多精彩内容 >>
提交
dab68ed8
编写于
7月 09, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add options support in notebook find widget.
上级
92b25083
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
53 addition
and
24 deletion
+53
-24
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindReplaceWidget.ts
...ontrib/codeEditor/browser/find/simpleFindReplaceWidget.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/contrib/find/findController.ts
...h/contrib/notebook/browser/contrib/find/findController.ts
+26
-10
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+10
-4
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
...h/contrib/notebook/browser/viewModel/codeCellViewModel.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel.ts
...ntrib/notebook/browser/viewModel/markdownCellViewModel.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
...h/contrib/notebook/browser/viewModel/notebookViewModel.ts
+3
-3
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+7
-0
未找到文件。
src/vs/workbench/contrib/codeEditor/browser/find/simpleFindReplaceWidget.ts
浏览文件 @
dab68ed8
...
...
@@ -62,7 +62,7 @@ export abstract class SimpleFindReplaceWidget extends Widget {
@
IContextViewService
private
readonly
_contextViewService
:
IContextViewService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
private
readonly
_themeService
:
IThemeService
,
pr
ivate
readonly
_state
:
FindReplaceState
=
new
FindReplaceState
(),
pr
otected
readonly
_state
:
FindReplaceState
=
new
FindReplaceState
(),
showOptionButtons
?:
boolean
)
{
super
();
...
...
src/vs/workbench/contrib/notebook/browser/contrib/find/findController.ts
浏览文件 @
dab68ed8
...
...
@@ -24,6 +24,9 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
getActiveNotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
FindReplaceState
}
from
'
vs/editor/contrib/find/findState
'
;
import
{
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
const
FIND_HIDE_TRANSITION
=
'
find-hide-transition
'
;
const
FIND_SHOW_TRANSITION
=
'
find-show-transition
'
;
...
...
@@ -45,9 +48,10 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
@
IContextViewService
contextViewService
:
IContextViewService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IThemeService
themeService
:
IThemeService
,
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
)
{
super
(
contextViewService
,
contextKeyService
,
themeService
);
super
(
contextViewService
,
contextKeyService
,
themeService
,
new
FindReplaceState
(),
true
);
DOM
.
append
(
this
.
_notebookEditor
.
getDomNode
(),
this
.
getDomNode
());
this
.
_findWidgetFocused
=
KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED
.
bindTo
(
contextKeyService
);
...
...
@@ -56,6 +60,10 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
this
.
_register
(
themeService
.
onDidColorThemeChange
(()
=>
{
this
.
updateTheme
(
themeService
.
getColorTheme
());
}));
this
.
_register
(
this
.
_state
.
onFindReplaceStateChange
(()
=>
{
this
.
onInputChanged
();
}));
}
private
_onFindInputKeyDown
(
e
:
IKeyboardEvent
):
void
{
...
...
@@ -63,7 +71,7 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
if
(
this
.
_findMatches
.
length
)
{
this
.
find
(
false
);
}
else
{
this
.
set
(
null
);
this
.
set
(
null
,
true
);
}
e
.
preventDefault
();
return
;
...
...
@@ -71,7 +79,7 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
if
(
this
.
_findMatches
.
length
)
{
this
.
find
(
true
);
}
else
{
this
.
set
(
null
);
this
.
set
(
null
,
true
);
}
e
.
preventDefault
();
return
;
...
...
@@ -80,13 +88,18 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
protected
onInputChanged
():
boolean
{
const
val
=
this
.
inputValue
;
const
wordSeparators
=
this
.
_configurationService
.
inspect
<
string
>
(
'
editor.wordSeparators
'
).
value
;
const
options
:
INotebookSearchOptions
=
{
regex
:
this
.
_getRegexValue
(),
wholeWord
:
this
.
_getWholeWordValue
(),
caseSensitive
:
this
.
_getCaseSensitiveValue
(),
wordSeparators
:
wordSeparators
};
if
(
val
)
{
this
.
_findMatches
=
this
.
_notebookEditor
.
viewModel
!
.
find
(
val
).
filter
(
match
=>
match
.
matches
.
length
>
0
);
this
.
_findMatches
=
this
.
_notebookEditor
.
viewModel
!
.
find
(
val
,
options
).
filter
(
match
=>
match
.
matches
.
length
>
0
);
this
.
set
(
this
.
_findMatches
,
false
);
if
(
this
.
_findMatches
.
length
)
{
return
true
;
}
else
{
return
false
;
}
}
else
{
this
.
set
([],
false
);
}
return
false
;
...
...
@@ -98,7 +111,7 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
}
if
(
!
this
.
_findMatchesStarts
)
{
this
.
set
(
this
.
_findMatches
);
this
.
set
(
this
.
_findMatches
,
true
);
}
else
{
const
totalVal
=
this
.
_findMatchesStarts
!
.
getTotalValue
();
const
nextVal
=
(
this
.
_currentMatch
+
(
previous
?
-
1
:
1
)
+
totalVal
)
%
totalVal
;
...
...
@@ -117,7 +130,7 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
}
if
(
!
this
.
_findMatchesStarts
)
{
this
.
set
(
this
.
_findMatches
);
this
.
set
(
this
.
_findMatches
,
true
);
}
const
nextIndex
=
this
.
_findMatchesStarts
!
.
getIndexOf
(
this
.
_currentMatch
);
...
...
@@ -179,7 +192,7 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
}
}
private
set
(
cellFindMatches
:
CellFindMatch
[]
|
null
):
void
{
private
set
(
cellFindMatches
:
CellFindMatch
[]
|
null
,
autoStart
:
boolean
):
void
{
if
(
!
cellFindMatches
||
!
cellFindMatches
.
length
)
{
this
.
_findMatches
=
[];
this
.
setAllFindMatchesDecorations
([]);
...
...
@@ -196,8 +209,11 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
// current match
this
.
constructFindMatchesStarts
();
this
.
_currentMatch
=
0
;
this
.
setCurrentFindMatchDecoration
(
0
,
0
);
if
(
autoStart
)
{
this
.
_currentMatch
=
0
;
this
.
setCurrentFindMatchDecoration
(
0
,
0
);
}
}
private
setCurrentFindMatchDecoration
(
cellIndex
:
number
,
matchIndex
:
number
)
{
...
...
@@ -270,7 +286,7 @@ export class NotebookFindWidget extends SimpleFindReplaceWidget implements INote
hide
()
{
super
.
hide
();
this
.
set
([]);
this
.
set
([]
,
false
);
if
(
this
.
_hideTimeout
===
null
)
{
if
(
this
.
_showTimeout
!==
null
)
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
dab68ed8
...
...
@@ -15,7 +15,7 @@ import * as model from 'vs/editor/common/model';
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
CursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
,
INotebookCellDecorationOptions
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
export
abstract
class
BaseCellViewModel
extends
Disposable
{
...
...
@@ -382,15 +382,21 @@ export abstract class BaseCellViewModel extends Disposable {
abstract
resolveTextModel
():
Promise
<
model
.
ITextModel
>
;
protected
cellStartFind
(
value
:
string
):
model
.
FindMatch
[]
|
null
{
protected
cellStartFind
(
value
:
string
,
options
:
INotebookSearchOptions
):
model
.
FindMatch
[]
|
null
{
let
cellMatches
:
model
.
FindMatch
[]
=
[];
if
(
this
.
assertTextModelAttached
())
{
cellMatches
=
this
.
textModel
!
.
findMatches
(
value
,
false
,
false
,
false
,
null
,
false
);
cellMatches
=
this
.
textModel
!
.
findMatches
(
value
,
false
,
options
.
regex
||
false
,
options
.
caseSensitive
||
false
,
options
.
wholeWord
?
options
.
wordSeparators
||
null
:
null
,
false
);
}
else
{
const
lineCount
=
this
.
textBuffer
.
getLineCount
();
const
fullRange
=
new
Range
(
1
,
1
,
lineCount
,
this
.
textBuffer
.
getLineLength
(
lineCount
)
+
1
);
const
searchParams
=
new
SearchParams
(
value
,
false
,
false
,
null
);
const
searchParams
=
new
SearchParams
(
value
,
options
.
regex
||
false
,
options
.
caseSensitive
||
false
,
options
.
wholeWord
?
options
.
wordSeparators
||
null
:
null
,
);
const
searchData
=
searchParams
.
parseSearchRequest
();
if
(
!
searchData
)
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
浏览文件 @
dab68ed8
...
...
@@ -11,7 +11,7 @@ import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer'
import
{
BOTTOM_CELL_TOOLBAR_HEIGHT
,
CELL_MARGIN
,
CELL_RUN_GUTTER
,
CELL_STATUSBAR_HEIGHT
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_MARGIN
,
EDITOR_TOP_PADDING
,
CELL_BOTTOM_MARGIN
,
CODE_CELL_LEFT_MARGIN
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFindMatch
,
CodeCellLayoutChangeEvent
,
CodeCellLayoutInfo
,
ICellViewModel
,
NotebookLayoutInfo
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
NotebookCellOutputsSplice
,
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BaseCellViewModel
}
from
'
./baseCellViewModel
'
;
import
{
NotebookEventDispatcher
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher
'
;
...
...
@@ -243,8 +243,8 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
private
readonly
_hasFindResult
=
this
.
_register
(
new
Emitter
<
boolean
>
());
public
readonly
hasFindResult
:
Event
<
boolean
>
=
this
.
_hasFindResult
.
event
;
startFind
(
value
:
string
):
CellFindMatch
|
null
{
const
matches
=
super
.
cellStartFind
(
value
);
startFind
(
value
:
string
,
options
:
INotebookSearchOptions
):
CellFindMatch
|
null
{
const
matches
=
super
.
cellStartFind
(
value
,
options
);
if
(
matches
===
null
)
{
return
null
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel.ts
浏览文件 @
dab68ed8
...
...
@@ -14,7 +14,7 @@ import { MarkdownRenderer } from 'vs/workbench/contrib/notebook/browser/view/ren
import
{
BaseCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel
'
;
import
{
EditorFoldingStateDelegate
}
from
'
vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookEventDispatcher
,
NotebookCellStateChangedEvent
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher
'
;
export
class
MarkdownCellViewModel
extends
BaseCellViewModel
implements
ICellViewModel
{
...
...
@@ -179,8 +179,8 @@ export class MarkdownCellViewModel extends BaseCellViewModel implements ICellVie
private
readonly
_hasFindResult
=
this
.
_register
(
new
Emitter
<
boolean
>
());
public
readonly
hasFindResult
:
Event
<
boolean
>
=
this
.
_hasFindResult
.
event
;
startFind
(
value
:
string
):
CellFindMatch
|
null
{
const
matches
=
super
.
cellStartFind
(
value
);
startFind
(
value
:
string
,
options
:
INotebookSearchOptions
):
CellFindMatch
|
null
{
const
matches
=
super
.
cellStartFind
(
value
,
options
);
if
(
matches
===
null
)
{
return
null
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
浏览文件 @
dab68ed8
...
...
@@ -24,7 +24,7 @@ import { NotebookEventDispatcher, NotebookMetadataChangedEvent } from 'vs/workbe
import
{
CellFoldingState
,
EditorFoldingStateDelegate
}
from
'
vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel
'
;
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
NotebookCellMetadata
,
INotebookSearchOptions
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
FoldingRegions
}
from
'
vs/editor/contrib/folding/foldingRanges
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
MarkdownRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/mdRenderer
'
;
...
...
@@ -1017,10 +1017,10 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
* Search in notebook text model
* @param value
*/
find
(
value
:
string
):
CellFindMatch
[]
{
find
(
value
:
string
,
options
:
INotebookSearchOptions
):
CellFindMatch
[]
{
const
matches
:
CellFindMatch
[]
=
[];
this
.
_viewCells
.
forEach
(
cell
=>
{
const
cellMatches
=
cell
.
startFind
(
value
);
const
cellMatches
=
cell
.
startFind
(
value
,
options
);
if
(
cellMatches
)
{
matches
.
push
(
cellMatches
);
}
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
dab68ed8
...
...
@@ -600,3 +600,10 @@ export enum NotebookEditorPriority {
default
=
'
default
'
,
option
=
'
option
'
,
}
export
interface
INotebookSearchOptions
{
regex
?:
boolean
;
wholeWord
?:
boolean
;
caseSensitive
?:
boolean
wordSeparators
?:
string
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录