@@ -93,8 +93,9 @@ module.exports = class DiffView {
9393
9494 /**
9595 * Called to move the current selection highlight to the next diff chunk.
96+ * @param isSyncScrollEnabled Only autoscroll one editor if sync scroll is enabled or we will get in an infinite loop
9697 */
97- nextDiff ( ) {
98+ nextDiff ( isSyncScrollEnabled ) {
9899 if ( this . _isSelectionActive ) {
99100 this . _selectedChunkIndex ++ ;
100101 if ( this . _selectedChunkIndex >= this . getNumDifferences ( ) ) {
@@ -104,7 +105,7 @@ module.exports = class DiffView {
104105 this . _isSelectionActive = true ;
105106 }
106107
107- var success = this . _selectChunk ( this . _selectedChunkIndex , true ) ;
108+ var success = this . _selectChunk ( this . _selectedChunkIndex , true , isSyncScrollEnabled ) ;
108109 if ( ! success ) {
109110 return - 1 ;
110111 }
@@ -114,8 +115,9 @@ module.exports = class DiffView {
114115
115116 /**
116117 * Called to move the current selection highlight to the previous diff chunk.
118+ * @param isSyncScrollEnabled Only autoscroll one editor if sync scroll is enabled or we will get in an infinite loop
117119 */
118- prevDiff ( ) {
120+ prevDiff ( isSyncScrollEnabled ) {
119121 if ( this . _isSelectionActive ) {
120122 this . _selectedChunkIndex -- ;
121123 if ( this . _selectedChunkIndex < 0 ) {
@@ -125,7 +127,7 @@ module.exports = class DiffView {
125127 this . _isSelectionActive = true ;
126128 }
127129
128- var success = this . _selectChunk ( this . _selectedChunkIndex , true ) ;
130+ var success = this . _selectChunk ( this . _selectedChunkIndex , true , isSyncScrollEnabled ) ;
129131 if ( ! success ) {
130132 return - 1 ;
131133 }
@@ -218,6 +220,10 @@ module.exports = class DiffView {
218220 }
219221 }
220222
223+ /**
224+ * Restores soft wrap to the appropriate editor.
225+ * @param editorIndex The index of the editor to restore soft wrap to.
226+ */
221227 restoreEditorSoftWrap ( editorIndex ) {
222228 if ( editorIndex === 1 ) {
223229 this . _editorDiffExtender1 . getEditor ( ) . setSoftWrapped ( true ) ;
@@ -243,10 +249,20 @@ module.exports = class DiffView {
243249 return Array . isArray ( this . _chunks ) ? this . _chunks . length : 0 ;
244250 }
245251
252+ /**
253+ * Gets the marker layers in use by the editors.
254+ * @return An object containing the marker layers and approriate information.
255+ */
246256 getMarkerLayers ( ) {
247257 return this . _markerLayers ;
248258 }
249259
260+ /**
261+ * Handles when the cursor moves in the editor. Will highlight chunks that have a cursor in them.
262+ * @param cursor The cursor object from the event.
263+ * @param oldBufferPosition The old position of the cursor in the buffer.
264+ * @param newBufferPosition The new position of the cursor in the buffer.
265+ */
250266 handleCursorChange ( cursor , oldBufferPosition , newBufferPosition ) {
251267 var editorIndex = ( cursor . editor === this . _editorDiffExtender1 . getEditor ( ) ) ? 1 : 2 ;
252268 var oldPositionChunkIndex = this . _getChunkIndexByLineNumber ( editorIndex , oldBufferPosition . row ) ;
@@ -272,8 +288,10 @@ module.exports = class DiffView {
272288 * given index.
273289 *
274290 * @param index The index of the diff chunk to highlight in both editors.
291+ * @param isNextOrPrev Whether we are moving to a direct sibling (if not, this is a click)
292+ * @param isSyncScrollEnabled Only autoscroll one editor if sync scroll is enabled or we will get in an infinite loop
275293 */
276- _selectChunk ( index , isNextOrPrev ) {
294+ _selectChunk ( index , isNextOrPrev , isSyncScrollEnabled ) {
277295 var diffChunk = this . _chunks [ index ] ;
278296 if ( diffChunk != null ) {
279297 diffChunk . isSelected = true ;
@@ -284,7 +302,7 @@ module.exports = class DiffView {
284302 this . _editorDiffExtender2 . deselectAllLines ( ) ;
285303 // scroll the editors
286304 this . _editorDiffExtender1 . getEditor ( ) . setCursorBufferPosition ( [ diffChunk . oldLineStart , 0 ] , { autoscroll : true } ) ;
287- this . _editorDiffExtender2 . getEditor ( ) . setCursorBufferPosition ( [ diffChunk . newLineStart , 0 ] , { autoscroll : true } ) ;
305+ this . _editorDiffExtender2 . getEditor ( ) . setCursorBufferPosition ( [ diffChunk . newLineStart , 0 ] , { autoscroll : ! isSyncScrollEnabled } ) ;
288306 }
289307
290308 // highlight selection in both editors
@@ -297,6 +315,12 @@ module.exports = class DiffView {
297315 return false ;
298316 }
299317
318+ /**
319+ * Gets the index of a chunk by the line number.
320+ * @param editorIndex The index of the editor to check.
321+ * @param lineNumber The line number to use to check if it is in a chunk.
322+ * @return The index of the chunk.
323+ */
300324 _getChunkIndexByLineNumber ( editorIndex , lineNumber ) {
301325 for ( var i = 0 ; i < this . _chunks . length ; i ++ ) {
302326 var diffChunk = this . _chunks [ i ] ;
0 commit comments