Skip to content

Commit

Permalink
[js] Work around the partial NFG support in the nqp level when moving…
Browse files Browse the repository at this point in the history
… a cursor by one grapheme
  • Loading branch information
pmurias committed Mar 5, 2018
1 parent f38633f commit 245102d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/core/Match.pm
Expand Up @@ -162,6 +162,12 @@ my class Match is Capture is Cool does NQPMatchRole {
)
}

#?if js
my sub move_cursor($target, $pos) {
nqp::chars(nqp::substrnfg(nqp::substr($target, $pos), 0, 1)) || 1;
}
#?endif

method CURSOR_OVERLAP() { # adapted from !cursor_more in nqp
nqp::stmts(
(my $new := nqp::create(self)),
Expand All @@ -183,7 +189,12 @@ my class Match is Capture is Cool does NQPMatchRole {
nqp::bindattr_i($new,$?CLASS,'$!pos',
nqp::if(
nqp::isge_i($!from,$!pos),
#?if !js
nqp::add_i($!from,1),
#?endif
#?if js
nqp::add_i($!from, move_cursor(self.target, $!pos)),
#?endif
$!pos
)
),
Expand Down

0 comments on commit 245102d

Please sign in to comment.