           wrapScreenColumn = lastWhitespaceScreenColumn + 1
           wrapBufferColumn = lastWhitespaceBufferColumn + 1
           wrapWidth = lastWhitespaceWidth + 1
-          trimmedWhitespaceStartScreenColumn = lastNonWhitespaceScreenColumn + 1
-          trimmedWhitespaceStartBufferColumn = lastNonWhitespaceBufferColumn + 1
+          trimmedWhitespaceStartScreenColumn = lastWordEndScreenColumn + 1
+          trimmedWhitespaceStartBufferColumn = lastWordEndBufferColumn + 1
 
           if wrapBufferColumn <= lastWrapBufferColumn
             wrapScreenColumn = screenColumn

            screenLineWidth += indentLength

        if character is ' ' or character is '\t'
          lastWhitespaceScreenColumn = screenColumn
          lastWhitespaceBufferColumn = bufferColumn
          lastWhitespaceWidth = screenLineWidth
        else
          lastNonWhitespaceScreenColumn = screenColumn
          lastNonWhitespaceBufferColumn = bufferColumn

        if foldEndBufferPosition?
          if screenColumn > tokensScreenExtent

      lastWhitespaceScreenColumn = -1
      lastWhitespaceBufferColumn = -1
      lastWhitespaceWidth = -1
      lastWordEndScreenColumn = -1
      lastWordEndBufferColumn = -1
      lastWrapBufferColumn = 0

      while bufferColumn <= bufferLineLength
