@@ -65,14 +65,20 @@ fn handle_open(
65) -> Transaction {
65) -> Transaction {
66 let mut ranges = SmallVec::with_capacity(selection.len());
66 let mut ranges = SmallVec::with_capacity(selection.len());
68 let mut transaction = Transaction::change_by_selection(doc, selection, |range| {
70 let mut transaction = Transaction::change_by_selection(doc, selection, |range| {
69 let pos = range.head;
71 let pos = range.head;
70 let next = next_char(doc, pos);
72 let next = next_char(doc, pos);
72− let head = pos + open.len_utf8();
74+ let head = pos + offs + open.len_utf8();
73 // if selection, retain anchor, if cursor, move over
75 // if selection, retain anchor, if cursor, move over
74 ranges.push(Range::new(
76 ranges.push(Range::new(
75− if range.is_empty() { head } else { range.anchor },
77+ if range.is_empty() {
@@ -88,6 +94,8 @@ fn handle_open(
88 pair.push_char(open);
94 pair.push_char(open);
89 pair.push_char(close);
95 pair.push_char(close);
91 (pos, pos, Some(pair))
99 (pos, pos, Some(pair))
@@ -99,14 +107,20 @@ fn handle_open(
99fn handle_close(doc: &Rope, selection: &Selection, _open: char, close: char) -> Transaction {
107fn handle_close(doc: &Rope, selection: &Selection, _open: char, close: char) -> Transaction {
100 let mut ranges = SmallVec::with_capacity(selection.len());
108 let mut ranges = SmallVec::with_capacity(selection.len());
102 let mut transaction = Transaction::change_by_selection(doc, selection, |range| {
112 let mut transaction = Transaction::change_by_selection(doc, selection, |range| {
103 let pos = range.head;
113 let pos = range.head;
104 let next = next_char(doc, pos);
114 let next = next_char(doc, pos);
106− let head = pos + close.len_utf8();
116+ let head = pos + offs + close.len_utf8();
107 // if selection, retain anchor, if cursor, move over
117 // if selection, retain anchor, if cursor, move over
108 ranges.push(Range::new(
118 ranges.push(Range::new(
109− if range.is_empty() { head } else { range.anchor },
119+ if range.is_empty() {
@@ -114,6 +128,8 @@ fn handle_close(doc: &Rope, selection: &Selection, _open: char, close: char) ->
114 // return transaction that moves past close
128 // return transaction that moves past close
115 (pos, pos, None) // no-op
129 (pos, pos, None) // no-op
131+ offs += close.len_utf8();
117 // TODO: else return (use default handler that inserts close)
133 // TODO: else return (use default handler that inserts close)
118 (pos, pos, Some(Tendril::from_char(close)))
134 (pos, pos, Some(Tendril::from_char(close)))