Skip to content
This repository was archived by the owner on Sep 8, 2018. It is now read-only.

Commit e3a3bc1

Browse files
author
Max Brunsfeld
authoredSep 6, 2018
Merge pull request #145 from t9md/disable-wrap
Add config option wrapAroundOnMoveToDiff
2 parents 0b7dccf + 89e9539 commit e3a3bc1

File tree

3 files changed

+32
-2
lines changed

3 files changed

+32
-2
lines changed
 

‎lib/git-diff-view.coffee

+4-2
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ class GitDiffView
5454
firstDiffLineNumber = Math.min(newStart - 1, firstDiffLineNumber)
5555

5656
# Wrap around to the first diff in the file
57-
nextDiffLineNumber = firstDiffLineNumber unless nextDiffLineNumber?
57+
if atom.config.get('git-diff.wrapAroundOnMoveToDiff') and not nextDiffLineNumber?
58+
nextDiffLineNumber = firstDiffLineNumber
5859

5960
@moveToLineNumber(nextDiffLineNumber)
6061

@@ -75,7 +76,8 @@ class GitDiffView
7576
lastDiffLineNumber = Math.max(newStart - 1, lastDiffLineNumber)
7677

7778
# Wrap around to the last diff in the file
78-
previousDiffLineNumber = lastDiffLineNumber if previousDiffLineNumber is -1
79+
if atom.config.get('git-diff.wrapAroundOnMoveToDiff') and previousDiffLineNumber is -1
80+
previousDiffLineNumber = lastDiffLineNumber
7981

8082
@moveToLineNumber(previousDiffLineNumber)
8183

‎package.json

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
"type": "boolean",
2222
"default": false,
2323
"description": "Show colored icons for added (`+`), modified (`·`) and removed (`-`) lines in the editor's gutter, instead of colored markers (`|`)."
24+
},
25+
"wrapAroundOnMoveToDiff": {
26+
"type": "boolean",
27+
"default": true,
28+
"description": "Wraps around to the first/last diff in the file when moving to next/previous diff."
2429
}
2530
}
2631
}

‎spec/git-diff-spec.coffee

+23
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,29 @@ describe "GitDiff package", ->
130130
atom.commands.dispatch(editorView, 'git-diff:move-to-previous-diff')
131131
expect(editor.getCursorBufferPosition()).toEqual [4, 4]
132132

133+
describe "when the wrapAroundOnMoveToDiff config option is false", ->
134+
beforeEach ->
135+
atom.config.set 'git-diff.wrapAroundOnMoveToDiff', false
136+
137+
it "does not wraps around to the first/last diff in the file", ->
138+
editor.insertText('a')
139+
editor.setCursorBufferPosition([5])
140+
editor.deleteLine()
141+
advanceClock(editor.getBuffer().stoppedChangingDelay)
142+
143+
editor.setCursorBufferPosition([0])
144+
atom.commands.dispatch(editorView, 'git-diff:move-to-next-diff')
145+
expect(editor.getCursorBufferPosition()).toEqual [4, 4]
146+
147+
atom.commands.dispatch(editorView, 'git-diff:move-to-next-diff')
148+
expect(editor.getCursorBufferPosition()).toEqual [4, 4]
149+
150+
atom.commands.dispatch(editorView, 'git-diff:move-to-previous-diff')
151+
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
152+
153+
atom.commands.dispatch(editorView, 'git-diff:move-to-previous-diff')
154+
expect(editor.getCursorBufferPosition()).toEqual [0, 0]
155+
133156
describe "when the showIconsInEditorGutter config option is true", ->
134157
beforeEach ->
135158
atom.config.set 'git-diff.showIconsInEditorGutter', true

0 commit comments

Comments
 (0)
This repository has been archived.