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
959564ae
Commit
959564ae
authored
8 years ago
by
Adrian Heine
Committed by
Marijn Haverbeke
8 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Use stickiness in cursorCoords for bidi
parent
8ef8555e
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/measurement/position_measurement.js
+31
-19
31 additions, 19 deletions
src/measurement/position_measurement.js
src/util/bidi.js
+10
-19
10 additions, 19 deletions
src/util/bidi.js
with
41 additions
and
38 deletions
src/measurement/position_measurement.js
+
31
−
19
View file @
959564ae
...
...
@@ -2,7 +2,7 @@ import { buildLineContent, LineView } from "../line/line_data"
import
{
clipPos
,
Pos
}
from
"
../line/pos
"
import
{
collapsedSpanAtEnd
,
heightAtLine
,
lineIsHidden
,
visualLine
}
from
"
../line/spans
"
import
{
getLine
,
lineAtHeight
,
lineNo
,
updateLineHeight
}
from
"
../line/utils_line
"
import
{
bidiLeft
,
bidiRight
,
bidiOther
,
getBidiPartAt
,
getOrder
,
lineLeft
,
lineRight
,
moveVisually
}
from
"
../util/bidi
"
import
{
bidiOther
,
getBidiPartAt
,
getOrder
,
lineLeft
,
lineRight
,
moveVisually
}
from
"
../util/bidi
"
import
{
ie
,
ie_version
}
from
"
../util/browser
"
import
{
elt
,
removeChildren
,
range
,
removeChildrenAndAdd
}
from
"
../util/dom
"
import
{
e_target
}
from
"
../util/event
"
...
...
@@ -334,6 +334,19 @@ export function charCoords(cm, pos, context, lineObj, bias) {
// Returns a box for a given cursor position, which may have an
// 'other' property containing the position of the secondary cursor
// on a bidi boundary.
// A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
// and after `char - 1` in writing order of `char - 1`
// A cursor Pos(line, char, "after") is on the same visual line as `char`
// and before `char` in writing order of `char`
// Examples (upper-case letters are RTL, lower-case are LTR):
// Pos(0, 1, ...)
// before after
// ab a|b a|b
// aB a|B aB|
// Ab |Ab A|b
// AB B|A B|A
// Every position after the last character on a line is considered to stick
// to the last character on the line.
export
function
cursorCoords
(
cm
,
pos
,
context
,
lineObj
,
preparedMeasure
,
varHeight
)
{
lineObj
=
lineObj
||
getLine
(
cm
.
doc
,
pos
.
line
)
if
(
!
preparedMeasure
)
preparedMeasure
=
prepareMeasureForLine
(
cm
,
lineObj
)
...
...
@@ -342,25 +355,24 @@ export function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeig
if
(
right
)
m
.
left
=
m
.
right
;
else
m
.
right
=
m
.
left
return
intoCoordSystem
(
cm
,
lineObj
,
m
,
context
)
}
function
getBidi
(
ch
,
partPos
)
{
let
part
=
order
[
partPos
],
right
=
part
.
level
%
2
if
(
ch
=
=
bidiLeft
(
part
)
&&
partPos
&&
part
.
level
<
order
[
partPos
-
1
].
level
)
{
part
=
order
[
--
partPos
]
ch
=
bidiRight
(
part
)
-
(
part
.
level
%
2
?
0
:
1
)
right
=
true
}
else
if
(
ch
==
bidiRight
(
part
)
&&
partPos
<
order
.
length
-
1
&&
part
.
level
<
order
[
partPos
+
1
].
level
)
{
part
=
order
[
++
partPos
]
ch
=
bidiLeft
(
part
)
-
part
.
level
%
2
right
=
false
}
if
(
right
&&
ch
==
part
.
to
&&
ch
>
part
.
from
)
return
get
(
ch
-
1
)
return
get
(
ch
,
righ
t
)
let
order
=
getOrder
(
lineObj
),
ch
=
pos
.
ch
,
sticky
=
pos
.
sticky
if
(
ch
>=
lineObj
.
text
.
length
)
{
ch
=
lineObj
.
text
.
length
sticky
=
"
before
"
}
else
if
(
ch
<
=
0
)
{
ch
=
0
sticky
=
"
after
"
}
if
(
!
order
)
return
get
(
sticky
==
"
before
"
?
ch
-
1
:
ch
,
sticky
==
"
before
"
)
function
getBidi
(
ch
,
partPos
,
invert
)
{
let
part
=
order
[
partPos
],
right
=
(
part
.
level
%
2
)
!=
0
return
get
(
invert
?
ch
-
1
:
ch
,
right
!=
inver
t
)
}
let
order
=
getOrder
(
lineObj
),
ch
=
pos
.
ch
if
(
!
order
)
return
get
(
pos
.
sticky
==
"
before
"
?
ch
-
1
:
ch
,
pos
.
sticky
==
"
before
"
)
let
partPos
=
getBidiPartAt
(
order
,
ch
)
let
val
=
getBidi
(
ch
,
partPos
)
if
(
bidiOther
!=
null
)
val
.
other
=
getBidi
(
ch
,
bidiOther
)
let
partPos
=
getBidiPartAt
(
order
,
ch
,
sticky
)
let
other
=
bidiOther
let
val
=
getBidi
(
ch
,
partPos
,
sticky
==
"
before
"
)
if
(
other
!=
null
)
val
.
other
=
getBidi
(
ch
,
other
,
sticky
!=
"
before
"
)
return
val
}
...
...
This diff is collapsed.
Click to expand it.
src/util/bidi.js
+
10
−
19
View file @
959564ae
...
...
@@ -25,33 +25,24 @@ export function lineRight(line) {
return
bidiRight
(
lst
(
order
))
}
function
compareBidiLevel
(
order
,
a
,
b
)
{
let
linedir
=
order
[
0
].
level
if
(
a
==
linedir
)
return
true
if
(
b
==
linedir
)
return
false
return
a
<
b
}
export
let
bidiOther
=
null
export
function
getBidiPartAt
(
order
,
pos
)
{
export
function
getBidiPartAt
(
order
,
ch
,
sticky
)
{
let
found
bidiOther
=
null
for
(
let
i
=
0
;
i
<
order
.
length
;
++
i
)
{
let
cur
=
order
[
i
]
if
(
cur
.
from
<
pos
&&
cur
.
to
>
pos
)
return
i
if
((
cur
.
from
==
pos
||
cur
.
to
==
pos
))
{
if
(
found
==
null
)
{
found
=
i
}
else
if
(
compareBidiLevel
(
order
,
cur
.
level
,
order
[
found
].
level
))
{
if
(
cur
.
from
!=
cur
.
to
)
bidiOther
=
found
return
i
}
else
{
if
(
cur
.
from
!=
cur
.
to
)
bidiOther
=
i
return
found
}
if
(
cur
.
from
<
ch
&&
cur
.
to
>
ch
)
return
i
if
(
cur
.
to
==
ch
)
{
if
(
cur
.
from
!=
cur
.
to
&&
sticky
==
"
before
"
)
found
=
i
else
bidiOther
=
i
}
if
(
cur
.
from
==
ch
)
{
if
(
cur
.
from
!=
cur
.
to
&&
sticky
!=
"
before
"
)
found
=
i
else
bidiOther
=
i
}
}
return
found
return
found
!=
null
?
found
:
bidiOther
}
function
moveInLine
(
line
,
pos
,
dir
,
byUnit
)
{
...
...
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