@@ -54,7 +54,10 @@ export class DOMChange {
5454 anchor = view . state . doc . length
5555 }
5656 }
57- this . newSel = EditorSelection . single ( anchor , head )
57+ if ( view . inputState . composing > - 1 && view . state . selection . ranges . length > 1 )
58+ this . newSel = view . state . selection . replaceRange ( EditorSelection . range ( anchor , head ) )
59+ else
60+ this . newSel = EditorSelection . single ( anchor , head )
5861 }
5962 }
6063}
@@ -218,17 +221,17 @@ function applyDefaultInsert(view: EditorView, change: {from: number, to: number,
218221 } else {
219222 compositionRange = view . state . doc . lineAt ( sel . head )
220223 }
221- let offset = sel . to - change . to , size = sel . to - sel . from
224+ let offset = sel . to - change . to
222225 tr = startState . changeByRange ( range => {
223226 if ( range . from == sel . from && range . to == sel . to )
224227 return { changes, range : mainSel || range . map ( changes ) }
225228 let to = range . to - offset , from = to - replaced . length
226- if ( range . to - range . from != size || view . state . sliceDoc ( from , to ) != replaced ||
229+ if ( view . state . sliceDoc ( from , to ) != replaced ||
227230 // Unfortunately, there's no way to make multiple
228231 // changes in the same node work without aborting
229232 // composition, so cursors in the composition range are
230233 // ignored.
231- range . to >= compositionRange . from && range . from <= compositionRange . to )
234+ to >= compositionRange . from && from <= compositionRange . to )
232235 return { range}
233236 let rangeChanges = startState . changes ( { from, to, insert : change ! . insert } ) , selOff = range . to - sel . to
234237 return {
0 commit comments