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

Commit a556db1

Browse files
committed
Store editor in ivar
1 parent 5ce1345 commit a556db1

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

Diff for: lib/diff-list-view.coffee

+8-11
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,26 @@ class DiffListView extends SelectListView
1313

1414
viewForItem: ({oldStart, newStart, oldLines, newLines}) ->
1515
bufferRow = if newStart > 0 then newStart - 1 else newStart
16+
lineText = @editor.lineForBufferRow(bufferRow) ? ''
1617
$$ ->
1718
@li class: 'two-lines', =>
18-
@div atom.workspace.getActiveEditor()?.lineForBufferRow(bufferRow), class: 'primary-line'
19+
@div lineText, class: 'primary-line'
1920
@div "-#{oldStart},#{oldLines} +#{newStart},#{newLines}", class: 'secondary-line'
2021

2122
populate: ->
22-
if editor = atom.workspace.getActiveEditor()
23-
diffs = atom.project.getRepo()?.getLineDiffs(editor.getPath(), editor.getText()) ? []
24-
@setItems(diffs)
23+
diffs = atom.project.getRepo()?.getLineDiffs(@editor.getPath(), @editor.getText()) ? []
24+
@setItems(diffs)
2525

2626
toggle: ->
2727
if @hasParent()
2828
@cancel()
29-
else
29+
else if @editor = atom.workspace.getActiveEditor()
3030
@populate()
3131
@attach()
3232

3333
confirmed: ({newStart})->
3434
@cancel()
3535

36-
editorView = atom.workspaceView.getActiveView()
37-
if editor = editorView?.getEditor?()
38-
bufferRow = if newStart > 0 then newStart - 1 else newStart
39-
editorView.scrollToBufferPosition([bufferRow, 0], center: true)
40-
editor.setCursorBufferPosition([bufferRow, 0])
41-
editor.moveCursorToFirstCharacterOfLine()
36+
bufferRow = if newStart > 0 then newStart - 1 else newStart
37+
@editor.setCursorBufferPosition([bufferRow, 0], autoscroll: true)
38+
@editor.moveCursorToFirstCharacterOfLine()

0 commit comments

Comments
 (0)