fix multicursor snippet placeholder directions (#8423)
This commit is contained in:
parent
1297d924e7
commit
4e86d1c35a
1 changed files with 10 additions and 10 deletions
|
@ -445,36 +445,36 @@ pub mod util {
|
||||||
// the tabstop closest to the range simply replaces `head` while anchor remains in place
|
// the tabstop closest to the range simply replaces `head` while anchor remains in place
|
||||||
// the remaining tabstops receive their own single-width cursor
|
// the remaining tabstops receive their own single-width cursor
|
||||||
if range.head < range.anchor {
|
if range.head < range.anchor {
|
||||||
let first_tabstop = tabstop_anchor + tabstops[0].1;
|
let last_idx = tabstops.len() - 1;
|
||||||
|
let last_tabstop = tabstop_anchor + tabstops[last_idx].0;
|
||||||
|
|
||||||
// if selection is forward but was moved to the right it is
|
// if selection is forward but was moved to the right it is
|
||||||
// contained entirely in the replacement text, just do a point
|
// contained entirely in the replacement text, just do a point
|
||||||
// selection (fallback below)
|
// selection (fallback below)
|
||||||
if range.anchor >= first_tabstop {
|
if range.anchor > last_tabstop {
|
||||||
let range = Range::new(range.anchor, first_tabstop);
|
let range = Range::new(range.anchor, last_tabstop);
|
||||||
mapped_selection.push(range);
|
mapped_selection.push(range);
|
||||||
let rem_tabstops = tabstops[1..]
|
let rem_tabstops = tabstops[..last_idx]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tabstop| Range::point(tabstop_anchor + tabstop.1));
|
.map(|tabstop| Range::point(tabstop_anchor + tabstop.0));
|
||||||
mapped_selection.extend(rem_tabstops);
|
mapped_selection.extend(rem_tabstops);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let last_idx = tabstops.len() - 1;
|
let first_tabstop = tabstop_anchor + tabstops[0].0;
|
||||||
let last_tabstop = tabstop_anchor + tabstops[last_idx].1;
|
|
||||||
|
|
||||||
// if selection is forward but was moved to the right it is
|
// if selection is forward but was moved to the right it is
|
||||||
// contained entirely in the replacement text, just do a point
|
// contained entirely in the replacement text, just do a point
|
||||||
// selection (fallback below)
|
// selection (fallback below)
|
||||||
if range.anchor <= last_tabstop {
|
if range.anchor < first_tabstop {
|
||||||
// we can't properly compute the the next grapheme
|
// we can't properly compute the the next grapheme
|
||||||
// here because the transaction hasn't been applied yet
|
// here because the transaction hasn't been applied yet
|
||||||
// that is not a problem because the range gets grapheme aligned anyway
|
// that is not a problem because the range gets grapheme aligned anyway
|
||||||
// tough so just adding one will always cause head to be grapheme
|
// tough so just adding one will always cause head to be grapheme
|
||||||
// aligned correctly when applied to the document
|
// aligned correctly when applied to the document
|
||||||
let range = Range::new(range.anchor, last_tabstop + 1);
|
let range = Range::new(range.anchor, first_tabstop + 1);
|
||||||
mapped_selection.push(range);
|
mapped_selection.push(range);
|
||||||
let rem_tabstops = tabstops[..last_idx]
|
let rem_tabstops = tabstops[1..]
|
||||||
.iter()
|
.iter()
|
||||||
.map(|tabstop| Range::point(tabstop_anchor + tabstop.0));
|
.map(|tabstop| Range::point(tabstop_anchor + tabstop.0));
|
||||||
mapped_selection.extend(rem_tabstops);
|
mapped_selection.extend(rem_tabstops);
|
||||||
|
|
Loading…
Add table
Reference in a new issue