Skip to content

Commit

Permalink
Updated to get rid of deprecated use of undo: 'skip', attempt 2 (#5)
Browse files Browse the repository at this point in the history
* Updated to get rid of deprecated use of undo: 'skip'
* Use `editor.buffer.groupLastChanges()` instead of `editor.groupLastChanges()` to avoid jumping cursor issue when moving across empty lines.

Fixes #3
  • Loading branch information
Doug Watkins authored and sompylasar committed Aug 8, 2018
1 parent 8c36013 commit 378f988
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/atom-cursor-indent.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ ALL_WHITESPACE_REGEXP = /^\s*$/
debugLog = (name) ->
if (isDebug)
console.log.apply(console, [ 'atom-cursor-indent:' + name ].concat( [].slice.call(arguments, 1) ))


nextTick = () ->
return new Promise((resolve) ->
process.nextTick(resolve)
Expand Down Expand Up @@ -92,7 +92,8 @@ removeTrailingWhitespace = (editor, lineInfo, keepColumn = 0) ->
trailingWhitespaceBufferRange = new Range(currLineEndNoWhitespaceBufferPos, lineInfo.end.bufferPos)
trailingWhitespaceBufferText = editor.getTextInBufferRange(trailingWhitespaceBufferRange)
if (trailingWhitespaceBufferText != '')
editor.setTextInBufferRange(trailingWhitespaceBufferRange, '', { undo: 'skip' })
editor.setTextInBufferRange(trailingWhitespaceBufferRange, '')
editor.buffer.groupLastChanges()
return true
return

Expand All @@ -104,7 +105,8 @@ removeIndentWhitespace = (editor, lineInfo) ->
lineBufferRange = new Range(lineInfo.start.bufferPos, lineInfo.end.bufferPos)
lineBufferText = lineInfo.bufferText
if (lineBufferText != '')
editor.setTextInBufferRange(lineBufferRange, '', { undo: 'skip' })
editor.setTextInBufferRange(lineBufferRange, '')
editor.buffer.groupLastChanges()
return true
return

Expand All @@ -119,7 +121,8 @@ setIndentationForBufferRowWithoutUndo = (editor, bufferRow, newLevel) ->
nextIndentString: nextIndentString,
})
prevIndentBufferRange = [[bufferRow, 0], [bufferRow, prevIndentString.length]]
editor.setTextInBufferRange(prevIndentBufferRange, nextIndentString, { undo: 'skip' })
editor.setTextInBufferRange(prevIndentBufferRange, nextIndentString)
editor.buffer.groupLastChanges()
return true
return

Expand Down

0 comments on commit 378f988

Please sign in to comment.