Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
be298bfd
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,发现更多精彩内容 >>
提交
be298bfd
编写于
7月 15, 2016
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #9326
上级
8eeb1f6d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
18 addition
and
92 deletion
+18
-92
src/vs/workbench/parts/search/browser/searchResultsView.ts
src/vs/workbench/parts/search/browser/searchResultsView.ts
+3
-2
src/vs/workbench/parts/search/browser/searchViewlet.ts
src/vs/workbench/parts/search/browser/searchViewlet.ts
+2
-2
src/vs/workbench/parts/search/browser/searchWidget.ts
src/vs/workbench/parts/search/browser/searchWidget.ts
+5
-5
src/vs/workbench/parts/search/common/searchModel.ts
src/vs/workbench/parts/search/common/searchModel.ts
+8
-15
src/vs/workbench/parts/search/test/common/searchModel.test.ts
...vs/workbench/parts/search/test/common/searchModel.test.ts
+0
-68
未找到文件。
src/vs/workbench/parts/search/browser/searchResultsView.ts
浏览文件 @
be298bfd
...
...
@@ -19,7 +19,7 @@ import { LeftRightWidget, IRenderer } from 'vs/base/browser/ui/leftRightWidget/l
import
{
ITree
,
IElementCallback
,
IDataSource
,
ISorter
,
IAccessibilityProvider
,
IFilter
}
from
'
vs/base/parts/tree/browser/tree
'
;
import
{
ClickBehavior
,
DefaultController
}
from
'
vs/base/parts/tree/browser/treeDefaults
'
;
import
{
ContributableActionProvider
}
from
'
vs/workbench/browser/actionBarRegistry
'
;
import
{
Match
,
SearchResult
,
FileMatch
,
FileMatchOrMatch
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
Match
,
SearchResult
,
FileMatch
,
FileMatchOrMatch
,
SearchModel
}
from
'
vs/workbench/parts/search/common/searchModel
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
IKeyboardEvent
}
from
'
vs/base/browser/keyboardEvent
'
;
...
...
@@ -167,8 +167,9 @@ export class SearchRenderer extends ActionsRenderer {
elements
.
push
(
'
<span>
'
);
elements
.
push
(
strings
.
escape
(
preview
.
before
));
let
searchModel
:
SearchModel
=
(
<
SearchResult
>
tree
.
getInput
()).
searchModel
;
let
showReplaceText
=
(
<
SearchResult
>
tree
.
getInput
()).
searchModel
.
hasReplaceString
()
;
let
showReplaceText
=
searchModel
.
isReplaceActive
()
&&
!!
searchModel
.
replaceString
;
elements
.
push
(
'
</span><span class="
'
+
(
showReplaceText
?
'
replace
'
:
''
)
+
'
findInFileMatch">
'
);
elements
.
push
(
strings
.
escape
(
preview
.
inside
));
if
(
showReplaceText
)
{
...
...
src/vs/workbench/parts/search/browser/searchViewlet.ts
浏览文件 @
be298bfd
...
...
@@ -290,7 +290,7 @@ export class SearchViewlet extends Viewlet {
this
.
toUnbind
.
push
(
this
.
searchWidget
.
onReplaceToggled
(()
=>
this
.
onReplaceToggled
()));
this
.
toUnbind
.
push
(
this
.
searchWidget
.
onReplaceStateChange
((
state
)
=>
{
this
.
viewModel
.
replace
String
=
this
.
searchWidget
.
getReplaceValue
()
;
this
.
viewModel
.
replace
Active
=
state
;
this
.
tree
.
refresh
();
}));
this
.
toUnbind
.
push
(
this
.
searchWidget
.
onReplaceValueChanged
((
value
)
=>
{
...
...
@@ -902,7 +902,7 @@ export class SearchViewlet extends Viewlet {
this
.
telemetryService
.
publicLog
(
'
searchResultChosen
'
);
return
this
.
viewModel
.
hasReplaceString
(
)
?
this
.
openReplacePreviewEditor
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
)
:
this
.
open
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
);
return
(
this
.
viewModel
.
isReplaceActive
()
&&
!!
this
.
viewModel
.
replaceString
)
?
this
.
openReplacePreviewEditor
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
)
:
this
.
open
(
lineMatch
,
preserveFocus
,
sideBySide
,
pinned
);
}
public
open
(
element
:
FileMatchOrMatch
,
preserveFocus
?:
boolean
,
sideBySide
?:
boolean
,
pinned
?:
boolean
):
TPromise
<
any
>
{
...
...
src/vs/workbench/parts/search/browser/searchWidget.ts
浏览文件 @
be298bfd
...
...
@@ -89,8 +89,8 @@ export class SearchWidget extends Widget {
private
_onReplaceToggled
=
this
.
_register
(
new
Emitter
<
void
>
());
public
onReplaceToggled
:
Event
<
void
>
=
this
.
_onReplaceToggled
.
event
;
private
_onReplaceStateChange
=
this
.
_register
(
new
Emitter
<
void
>
());
public
onReplaceStateChange
:
Event
<
void
>
=
this
.
_onReplaceStateChange
.
event
;
private
_onReplaceStateChange
=
this
.
_register
(
new
Emitter
<
boolean
>
());
public
onReplaceStateChange
:
Event
<
boolean
>
=
this
.
_onReplaceStateChange
.
event
;
private
_onReplaceValueChanged
=
this
.
_register
(
new
Emitter
<
string
>
());
public
onReplaceValueChanged
:
Event
<
string
>
=
this
.
_onReplaceValueChanged
.
event
;
...
...
@@ -143,7 +143,7 @@ export class SearchWidget extends Widget {
}
public
getReplaceValue
():
string
{
return
this
.
isReplaceActive
()
?
this
.
replaceInput
.
value
:
null
;
return
this
.
replaceInput
.
value
;
}
public
toggleReplace
(
show
?:
boolean
):
void
{
...
...
@@ -229,8 +229,8 @@ export class SearchWidget extends Widget {
let
currentState
=
this
.
isReplaceActive
();
let
newState
=
this
.
isReplaceShown
()
&&
this
.
replaceAllAction
.
enabled
;
if
(
currentState
!==
newState
)
{
this
.
replaceActive
.
set
(
this
.
isReplaceShown
()
&&
this
.
replaceAllAction
.
enabled
);
this
.
_onReplaceStateChange
.
fire
();
this
.
replaceActive
.
set
(
newState
);
this
.
_onReplaceStateChange
.
fire
(
newState
);
}
}
...
...
src/vs/workbench/parts/search/common/searchModel.ts
浏览文件 @
be298bfd
...
...
@@ -407,6 +407,7 @@ export class SearchModel extends Disposable {
private
_searchResult
:
SearchResult
;
private
_searchQuery
:
ISearchQuery
=
null
;
private
_replaceActive
:
boolean
=
false
;
private
_replaceString
:
string
=
null
;
private
_replacePattern
:
ReplacePattern
=
null
;
...
...
@@ -420,30 +421,22 @@ export class SearchModel extends Disposable {
this
.
_searchResult
=
this
.
instantiationService
.
createInstance
(
SearchResult
,
this
);
}
/**
* Return true if replace is enabled otherwise false
*/
public
isReplaceActive
():
boolean
{
return
this
.
_replace
String
!==
null
&&
this
.
_replaceString
!==
void
0
;
return
this
.
_replace
Active
;
}
/**
* Return true if replace is enabled and replace text is not empty, otherwise false.
* This is necessary in cases handling empty replace text when replace is active.
*/
public
hasReplaceString
():
boolean
{
return
this
.
isReplaceActive
()
&&
!!
this
.
_replaceString
;
public
set
replaceActive
(
replaceActive
:
boolean
)
{
this
.
_replaceActive
=
replaceActive
;
}
/**
* Returns the text to replace.
* Can be null if replace is not enabled. Use replace() before.
* Can be empty.
*/
public
get
replacePattern
():
ReplacePattern
{
return
this
.
_replacePattern
;
}
public
get
replaceString
():
string
{
return
this
.
_replaceString
;
}
public
set
replaceString
(
replaceString
:
string
)
{
this
.
_replaceString
=
replaceString
;
if
(
this
.
_searchQuery
)
{
...
...
src/vs/workbench/parts/search/test/common/searchModel.test.ts
浏览文件 @
be298bfd
...
...
@@ -222,74 +222,6 @@ suite('SearchModel', () => {
assert
.
ok
(
target
.
calledOnce
);
});
test
(
'
Search Model: isReplaceActive return false if no replace text is set
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
assert
.
ok
(
!
testObject
.
isReplaceActive
());
});
test
(
'
Search Model: isReplaceActive return false if replace text is set to null
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
null
;
assert
.
ok
(
!
testObject
.
isReplaceActive
());
});
test
(
'
Search Model: isReplaceActive return false if replace text is set to undefined
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
void
0
;
assert
.
ok
(
!
testObject
.
isReplaceActive
());
});
test
(
'
Search Model: isReplaceActive return true if replace text is set to empty string
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
''
;
assert
.
ok
(
testObject
.
isReplaceActive
());
});
test
(
'
Search Model: isReplaceActive return true if replace text is set to non empty string
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
'
some value
'
;
assert
.
ok
(
testObject
.
isReplaceActive
());
});
test
(
'
Search Model: hasReplaceText return false if no replace text is set
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
assert
.
ok
(
!
testObject
.
hasReplaceString
());
});
test
(
'
Search Model: hasReplaceText return false if replace text is set to null
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
null
;
assert
.
ok
(
!
testObject
.
hasReplaceString
());
});
test
(
'
Search Model: hasReplaceText return false if replace text is set to undefined
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
void
0
;
assert
.
ok
(
!
testObject
.
hasReplaceString
());
});
test
(
'
Search Model: hasReplaceText return false if replace text is set to empty string
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
''
;
assert
.
ok
(
!
testObject
.
hasReplaceString
());
});
test
(
'
Search Model: hasReplaceText return true if replace text is set to non empty string
'
,
function
()
{
let
testObject
:
SearchModel
=
instantiationService
.
createInstance
(
SearchModel
);
testObject
.
replaceString
=
'
some value
'
;
assert
.
ok
(
testObject
.
hasReplaceString
());
});
function
aRawMatch
(
resource
:
string
,
...
lineMatches
:
ILineMatch
[]):
IFileMatch
{
return
{
resource
:
URI
.
parse
(
resource
),
lineMatches
};
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录