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
1696785c
Commit
1696785c
authored
11 years ago
by
Marijn Haverbeke
Browse files
Options
Downloads
Patches
Plain Diff
[sublime keymap] Fix findUnder, add test
Issue #2380
parent
38afa1e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
keymap/sublime.js
+16
-25
16 additions, 25 deletions
keymap/sublime.js
test/sublime_test.js
+8
-0
8 additions, 0 deletions
test/sublime_test.js
with
24 additions
and
25 deletions
keymap/sublime.js
+
16
−
25
View file @
1696785c
...
...
@@ -455,40 +455,31 @@
});
};
function
findAndGoTo
(
cm
,
next
)
{
function
findAndGoTo
(
cm
,
forward
)
{
var
from
=
cm
.
getCursor
(
"
from
"
),
to
=
cm
.
getCursor
(
"
to
"
);
var
selected
=
CodeMirror
.
cmpPos
(
from
,
to
);
if
(
!
selected
)
{
if
(
CodeMirror
.
cmpPos
(
from
,
to
)
==
0
)
{
var
word
=
wordAt
(
cm
,
from
);
if
(
!
word
.
word
)
return
;
cm
.
setSelection
(
word
.
from
,
word
.
to
);
from
=
word
.
from
;
to
=
word
.
to
;
selected
=
true
;
}
if
(
selected
){
var
query
=
cm
.
getRange
(
from
,
to
);
var
searchstart
=
(
next
?
to
:
{
line
:
from
.
line
,
ch
:
from
.
ch
-
1
});
var
cur
=
cm
.
getSearchCursor
(
query
,
searchstart
);
var
found
;
if
(
next
)
found
=
cur
.
findNext
();
else
found
=
cur
.
findPrevious
();
if
(
found
)
cm
.
setSelection
(
cur
.
from
(),
cur
.
to
());
else
{
if
(
next
){
cur
=
cm
.
getSearchCursor
(
query
,
Pos
(
cm
.
firstLine
(),
0
));
cur
.
findNext
();
}
else
{
cur
=
cm
.
getSearchCursor
(
query
,
Pos
(
cm
.
lastLine
()
+
1
,
0
));
cur
.
findPrevious
();
}
var
query
=
cm
.
getRange
(
from
,
to
);
var
cur
=
cm
.
getSearchCursor
(
query
,
forward
?
to
:
from
);
if
(
forward
?
cur
.
findNext
()
:
cur
.
findPrevious
())
{
cm
.
setSelection
(
cur
.
from
(),
cur
.
to
());
}
else
{
cur
=
cm
.
getSearchCursor
(
query
,
forward
?
Pos
(
cm
.
firstLine
(),
0
)
:
cm
.
clipPos
(
Pos
(
cm
.
lastLine
())));
if
(
forward
?
cur
.
findNext
()
:
cur
.
findPrevious
())
cm
.
setSelection
(
cur
.
from
(),
cur
.
to
());
}
else
if
(
word
)
cm
.
setSelection
(
from
,
to
);
}
};
cmds
[
map
[
ctrl
+
"
F3
"
]
=
"
findUnder
"
]
=
function
(
cm
)
{
findAndGoTo
(
cm
,
true
);};
cmds
[
map
[
ctrl
+
"
Shift-F3
"
]
=
"
findUnderPrevious
"
]
=
function
(
cm
)
{
findAndGoTo
(
cm
,
false
);};
cmds
[
map
[
ctrl
+
"
F3
"
]
=
"
findUnder
"
]
=
function
(
cm
)
{
findAndGoTo
(
cm
,
true
);
};
cmds
[
map
[
"
Shift-
"
+
ctrl
+
"
F3
"
]
=
"
findUnderPrevious
"
]
=
function
(
cm
)
{
findAndGoTo
(
cm
,
false
);
};
map
[
"
Shift-
"
+
ctrl
+
"
[
"
]
=
"
fold
"
;
map
[
"
Shift-
"
+
ctrl
+
"
]
"
]
=
"
unfold
"
;
...
...
This diff is collapsed.
Click to expand it.
test/sublime_test.js
+
8
−
0
View file @
1696785c
...
...
@@ -286,4 +286,12 @@
Pos
(
0
,
1
),
"
swapWithSublimeMark
"
,
at
(
1
,
1
),
"
swapWithSublimeMark
"
,
at
(
0
,
1
),
"
deleteToSublimeMark
"
,
val
(
"
aef
\n
ghi
"
),
"
sublimeYank
"
,
val
(
"
abc
\n
def
\n
ghi
"
),
at
(
1
,
1
));
stTest
(
"
findUnder
"
,
"
foo foobar a
"
,
"
findUnder
"
,
hasSel
(
0
,
4
,
0
,
7
),
"
findUnder
"
,
hasSel
(
0
,
0
,
0
,
3
),
"
findUnderPrevious
"
,
hasSel
(
0
,
4
,
0
,
7
),
"
findUnderPrevious
"
,
hasSel
(
0
,
0
,
0
,
3
),
Pos
(
0
,
4
),
"
findUnder
"
,
hasSel
(
0
,
4
,
0
,
10
),
Pos
(
0
,
11
),
"
findUnder
"
,
hasSel
(
0
,
11
,
0
,
11
));
})();
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