on master help sign in
fix multicursor snippet placeholder directions (#8423)
4e86d1cPascal Kuthe
helix-lsp/src/lib.rs+10−10
@@ -445,36 +445,36 @@ pub mod util {
445 // the tabstop closest to the range simply replaces `head` while anchor remains in place
445 // the tabstop closest to the range simply replaces `head` while anchor remains in place
446 // the remaining tabstops receive their own single-width cursor
446 // the remaining tabstops receive their own single-width cursor
447 if range.head < range.anchor {
447 if range.head < range.anchor {
448+ let last_idx = tabstops.len() - 1;
448− let first_tabstop = tabstop_anchor + tabstops[0].1;
449+ let last_tabstop = tabstop_anchor + tabstops[last_idx].0;
449
450
450 // if selection is forward but was moved to the right it is
451 // if selection is forward but was moved to the right it is
451 // contained entirely in the replacement text, just do a point
452 // contained entirely in the replacement text, just do a point
452 // selection (fallback below)
453 // selection (fallback below)
453− if range.anchor >= first_tabstop {
454+ if range.anchor > last_tabstop {
454− let range = Range::new(range.anchor, first_tabstop);
455+ let range = Range::new(range.anchor, last_tabstop);
455 mapped_selection.push(range);
456 mapped_selection.push(range);
456− let rem_tabstops = tabstops[1..]
457+ let rem_tabstops = tabstops[..last_idx]
457 .iter()
458 .iter()
458− .map(|tabstop| Range::point(tabstop_anchor + tabstop.1));
459+ .map(|tabstop| Range::point(tabstop_anchor + tabstop.0));
459 mapped_selection.extend(rem_tabstops);
460 mapped_selection.extend(rem_tabstops);
460 continue;
461 continue;
461 }
462 }
462 } else {
463 } else {
463− let last_idx = tabstops.len() - 1;
464− let last_tabstop = tabstop_anchor + tabstops[last_idx].1;
464+ let first_tabstop = tabstop_anchor + tabstops[0].0;
465
465
466 // if selection is forward but was moved to the right it is
466 // if selection is forward but was moved to the right it is
467 // contained entirely in the replacement text, just do a point
467 // contained entirely in the replacement text, just do a point
468 // selection (fallback below)
468 // selection (fallback below)
469− if range.anchor <= last_tabstop {
469+ if range.anchor < first_tabstop {
470 // we can't properly compute the the next grapheme
470 // we can't properly compute the the next grapheme
471 // here because the transaction hasn't been applied yet
471 // here because the transaction hasn't been applied yet
472 // that is not a problem because the range gets grapheme aligned anyway
472 // that is not a problem because the range gets grapheme aligned anyway
473 // tough so just adding one will always cause head to be grapheme
473 // tough so just adding one will always cause head to be grapheme
474 // aligned correctly when applied to the document
474 // aligned correctly when applied to the document
475− let range = Range::new(range.anchor, last_tabstop + 1);
475+ let range = Range::new(range.anchor, first_tabstop + 1);
476 mapped_selection.push(range);
476 mapped_selection.push(range);
477− let rem_tabstops = tabstops[..last_idx]
477+ let rem_tabstops = tabstops[1..]
478 .iter()
478 .iter()
479 .map(|tabstop| Range::point(tabstop_anchor + tabstop.0));
479 .map(|tabstop| Range::point(tabstop_anchor + tabstop.0));
480 mapped_selection.extend(rem_tabstops);
480 mapped_selection.extend(rem_tabstops);