Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CodeMirror
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Moritz Aurel Pascal Schubotz
CodeMirror
Commits
bb3aac30
Commit
bb3aac30
authored
9 years ago
by
Marijn Haverbeke
Browse files
Options
Downloads
Patches
Plain Diff
[search addon] Add some blank lines
parent
4c4c0c6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
addon/search/search.js
+11
-0
11 additions, 0 deletions
addon/search/search.js
with
11 additions
and
0 deletions
addon/search/search.js
+
11
−
0
View file @
bb3aac30
...
...
@@ -18,6 +18,7 @@
mod
(
CodeMirror
);
})(
function
(
CodeMirror
)
{
"
use strict
"
;
function
searchOverlay
(
query
,
caseInsensitive
)
{
if
(
typeof
query
==
"
string
"
)
query
=
new
RegExp
(
query
.
replace
(
/
[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]
/g
,
"
\\
$&
"
),
caseInsensitive
?
"
gi
"
:
"
g
"
);
...
...
@@ -42,16 +43,20 @@
this
.
posFrom
=
this
.
posTo
=
this
.
lastQuery
=
this
.
query
=
null
;
this
.
overlay
=
null
;
}
function
getSearchState
(
cm
)
{
return
cm
.
state
.
search
||
(
cm
.
state
.
search
=
new
SearchState
());
}
function
queryCaseInsensitive
(
query
)
{
return
typeof
query
==
"
string
"
&&
query
==
query
.
toLowerCase
();
}
function
getSearchCursor
(
cm
,
query
,
pos
)
{
// Heuristic: if the query string is all lowercase, do a case insensitive search.
return
cm
.
getSearchCursor
(
query
,
pos
,
queryCaseInsensitive
(
query
));
}
function
dialog
(
cm
,
text
,
shortText
,
deflt
,
f
)
{
if
(
cm
.
openDialog
)
cm
.
openDialog
(
text
,
f
,
{
value
:
deflt
,
selectValueOnOpen
:
true
});
else
f
(
prompt
(
shortText
,
deflt
));
...
...
@@ -60,6 +65,7 @@
if
(
cm
.
openConfirm
)
cm
.
openConfirm
(
text
,
fs
);
else
if
(
confirm
(
shortText
))
fs
[
0
]();
}
function
parseQuery
(
query
)
{
var
isRE
=
query
.
match
(
/^
\/(
.*
)\/([
a-z
]
*
)
$/
);
if
(
isRE
)
{
...
...
@@ -70,8 +76,10 @@
query
=
/x^/
;
return
query
;
}
var
queryDialog
=
'
Search: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>
'
;
function
doSearch
(
cm
,
rev
)
{
var
state
=
getSearchState
(
cm
);
if
(
state
.
query
)
return
findNext
(
cm
,
rev
);
...
...
@@ -92,6 +100,7 @@
});
});
}
function
findNext
(
cm
,
rev
)
{
cm
.
operation
(
function
()
{
var
state
=
getSearchState
(
cm
);
var
cursor
=
getSearchCursor
(
cm
,
state
.
query
,
rev
?
state
.
posFrom
:
state
.
posTo
);
...
...
@@ -103,6 +112,7 @@
cm
.
scrollIntoView
({
from
:
cursor
.
from
(),
to
:
cursor
.
to
()});
state
.
posFrom
=
cursor
.
from
();
state
.
posTo
=
cursor
.
to
();
});}
function
clearSearch
(
cm
)
{
cm
.
operation
(
function
()
{
var
state
=
getSearchState
(
cm
);
state
.
lastQuery
=
state
.
query
;
...
...
@@ -116,6 +126,7 @@
'
Replace: <input type="text" style="width: 10em" class="CodeMirror-search-field"/> <span style="color: #888" class="CodeMirror-search-hint">(Use /re/ syntax for regexp search)</span>
'
;
var
replacementQueryDialog
=
'
With: <input type="text" style="width: 10em" class="CodeMirror-search-field"/>
'
;
var
doReplaceConfirm
=
"
Replace? <button>Yes</button> <button>No</button> <button>Stop</button>
"
;
function
replace
(
cm
,
all
)
{
if
(
cm
.
getOption
(
"
readOnly
"
))
return
;
var
query
=
cm
.
getSelection
()
||
getSearchState
(
cm
).
lastQuery
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment