@@ -1718,17 +1718,18 @@ exports.copyAText = (atext1, atext2) => {
17181718} ;
17191719
17201720/**
1721- * Append the set of operations from atext to an assembler .
1721+ * Convert AText to a series of operations .
17221722 *
1723- * @param {AText } atext -
1724- * @param assem - Assembler like SmartOpAssembler TODO add desc
1723+ * @param {AText } atext - The AText to convert.
1724+ * @yields {Op}
1725+ * @returns {Generator<Op> }
17251726 */
1726- exports . appendATextToAssembler = ( atext , assem ) => {
1727+ exports . opsFromAText = function * ( atext ) {
17271728 // intentionally skips last newline char of atext
17281729 const iter = exports . opIterator ( atext . attribs ) ;
17291730 let lastOp = null ;
17301731 while ( iter . hasNext ( ) ) {
1731- if ( lastOp != null ) assem . append ( lastOp ) ;
1732+ if ( lastOp != null ) yield lastOp ;
17321733 lastOp = iter . next ( ) ;
17331734 }
17341735 if ( lastOp == null ) return ;
@@ -1741,11 +1742,24 @@ exports.appendATextToAssembler = (atext, assem) => {
17411742 const lastLineLength = atext . text . length - nextToLastNewlineEnd - 1 ;
17421743 lastOp . lines -- ;
17431744 lastOp . chars -= ( lastLineLength + 1 ) ;
1744- assem . append ( lastOp ) ;
1745+ yield copyOp ( lastOp ) ;
17451746 lastOp . lines = 0 ;
17461747 lastOp . chars = lastLineLength ;
17471748 }
1748- if ( lastOp . chars ) assem . append ( lastOp ) ;
1749+ if ( lastOp . chars ) yield lastOp ;
1750+ } ;
1751+
1752+ /**
1753+ * Append the set of operations from atext to an assembler.
1754+ *
1755+ * @deprecated Use `opsFromAText` instead.
1756+ * @param {AText } atext -
1757+ * @param assem - Assembler like SmartOpAssembler TODO add desc
1758+ */
1759+ exports . appendATextToAssembler = ( atext , assem ) => {
1760+ padutils . warnWithStack (
1761+ 'Changeset.appendATextToAssembler() is deprecated; use Changeset.opsFromAText() instead' ) ;
1762+ for ( const op of exports . opsFromAText ( atext ) ) assem . append ( op ) ;
17491763} ;
17501764
17511765/**
0 commit comments