This commit is contained in:
Corey Johnson & Nathan Sobo
2012-12-11 16:51:35 -08:00
10 changed files with 48 additions and 20 deletions

View File

@@ -65,6 +65,12 @@ public:
return CefV8Value::CreateInt(0);
}
git_index* index;
if (git_repository_index(&index, repo) == GIT_OK) {
git_index_read(index);
git_index_free(index);
}
unsigned int status = 0;
if (git_status_file(&status, repo, path) == GIT_OK) {
return CefV8Value::CreateInt(status);

View File

@@ -1005,12 +1005,12 @@ describe "Editor", ->
editor.addCursorAtBufferPosition([6,50])
[cursor1, cursor2] = editor.getCursors()
spyOn(editor, 'scrollTo')
spyOn(editor, 'scrollToPixelPosition')
cursor1.setScreenPosition([10, 10])
expect(editor.scrollTo).not.toHaveBeenCalled()
expect(editor.scrollToPixelPosition).not.toHaveBeenCalled()
cursor2.setScreenPosition([11, 11])
expect(editor.scrollTo).toHaveBeenCalled()
expect(editor.scrollToPixelPosition).toHaveBeenCalled()
describe "when the last cursor exceeds the upper or lower scroll margins", ->
describe "when the editor is taller than twice the vertical scroll margin", ->
@@ -1396,7 +1396,6 @@ describe "Editor", ->
describe "when lines are added", ->
beforeEach ->
editor.attachToDom(heightInLines: 5)
spyOn(editor, "scrollTo")
describe "when the change precedes the first rendered row", ->
it "inserts and removes rendered lines to account for upstream change", ->
@@ -1448,7 +1447,6 @@ describe "Editor", ->
describe "when lines are removed", ->
beforeEach ->
editor.attachToDom(heightInLines: 5)
spyOn(editor, "scrollTo")
it "sets the rendered screen line's width to either the max line length or the scollView's width (whichever is greater)", ->
maxLineLength = editor.maxScreenLineLength()
@@ -1614,7 +1612,6 @@ describe "Editor", ->
describe "when lines are inserted", ->
it "re-renders the correct line number range in the gutter", ->
spyOn(editor, 'scrollTo')
editor.scrollTop(3 * editor.lineHeight)
expect(editor.gutter.find('.line-number:first').text()).toBe '2'
expect(editor.gutter.find('.line-number:last').text()).toBe '11'

View File

@@ -158,3 +158,11 @@ describe "StatusBar", ->
fs.write(path, originalPathText)
rootView.getActiveEditor().getBuffer().trigger 'git-status-change'
expect(statusBar.gitStatusIcon).toHaveText('')
it "updates when the window receives focus", ->
fs.write(path, "i've changed for the worse")
rootView.open(path)
expect(statusBar.gitStatusIcon).toHaveText('\uf26d')
fs.write(path, originalPathText)
$(window).trigger 'focus'
expect(statusBar.gitStatusIcon).toHaveText('')

View File

@@ -497,7 +497,13 @@ class Editor extends View
scrollToBottom: ->
@scrollBottom(@screenLineCount() * @lineHeight)
scrollTo: (pixelPosition, options) ->
scrollToBufferPosition: (bufferPosition, options) ->
@scrollToPixelPosition(@pixelPositionForBufferPosition(bufferPosition), options)
scrollToScreenPosition: (screenPosition, options) ->
@scrollToPixelPosition(@pixelPositionForScreenPosition(screenPosition), options)
scrollToPixelPosition: (pixelPosition, options) ->
return unless @attached
@scrollVertically(pixelPosition, options)
@scrollHorizontally(pixelPosition)
@@ -800,11 +806,11 @@ class Editor extends View
autoscroll: (options={}) ->
for cursorView in @getCursorViews() when cursorView.needsAutoscroll()
@scrollTo(cursorView.getPixelPosition()) unless options.suppressAutoScroll
@scrollToPixelPosition(cursorView.getPixelPosition()) unless options.suppressAutoScroll
cursorView.autoscrolled()
for selectionView in @getSelectionViews() when selectionView.needsAutoscroll()
@scrollTo(selectionView.getCenterPixelPosition(), center: true)
@scrollToPixelPosition(selectionView.getCenterPixelPosition(), center: true)
selectionView.autoscrolled()
updateRenderedLines: ->
@@ -1025,6 +1031,9 @@ class Editor extends View
@renderedLines.find('.line').each (n) ->
console.log n, $(this).text()
pixelPositionForBufferPosition: (position) ->
@pixelPositionForScreenPosition(@screenPositionForBufferPosition(position))
pixelPositionForScreenPosition: (position) ->
position = Point.fromObject(position)
{ top: position.row * @lineHeight, left: position.column * @charWidth }

View File

@@ -19,7 +19,7 @@ class Git
getPath: -> @repo.getPath()
getWorkingDirectory: ->
repoPath = @repo.getPath()
repoPath = @getPath()
if repoPath
repoPath.substring(0, repoPath.length - 5)
@@ -35,11 +35,16 @@ class Git
isPathModified: (path) ->
modifiedFlags = @statusFlags.working_dir_modified |
@statusFlags.working_dir_delete |
@statusFlags.working_dir_typechange
@statusFlags.working_dir_typechange |
@statusFlags.index_modified |
@statusFlags.index_deleted |
@statusFlags.index_typechange
(@getPathStatus(path) & modifiedFlags) > 0
isPathNew: (path) ->
(@getPathStatus(path) & @statusFlags.working_dir_new) > 0
newFlags = @statusFlags.working_dir_new |
@statusFlags.index_new
(@getPathStatus(path) & newFlags) > 0
relativize: (path) ->
workingDirectory = @getWorkingDirectory()

View File

@@ -1,5 +1,6 @@
_ = require 'underscore'
{View, $$} = require 'space-pen'
$ = require 'jquery'
module.exports =
class StatusBar extends View
@@ -36,6 +37,7 @@ class StatusBar extends View
@updateCursorPositionText()
@editor.on 'cursor-move', => @updateCursorPositionText()
$(window).on 'focus', => @updateStatusBar()
@subscribeToBuffer()

View File

@@ -50,7 +50,9 @@ class OutlineView extends SelectList
confirmed : ({position, name}) ->
@cancel()
@rootView.getActiveEditor().setCursorBufferPosition(position)
editor = @rootView.getActiveEditor()
editor.scrollToBufferPosition(position, center: true)
editor.setCursorBufferPosition(position)
cancelled: ->
@miniEditor.setText('')

View File

@@ -88,4 +88,3 @@ class DirectoryView extends View
view = $(this).view()
view.entryStates = childEntryStates
view.expand()

View File

@@ -10,7 +10,7 @@ class FileView extends View
file: null
initialize: (@file) ->
@addClass('ignored') if new Git(@file.getPath()).isPathIgnored(@file.getPath())
@addClass('ignored') if new Git(@getPath()).isPathIgnored(@getPath())
getPath: ->
@file.path

View File

@@ -111,7 +111,7 @@ class TreeView extends ScrollView
switch e.originalEvent?.detail ? 1
when 1
@selectEntry(entry)
@openSelectedEntry(false) if (entry instanceof FileView)
@openSelectedEntry(false) if entry instanceof FileView
when 2
if entry.is('.selected.file')
@rootView.getActiveEditor().focus()
@@ -191,7 +191,7 @@ class TreeView extends ScrollView
expandDirectory: ->
selectedEntry = @selectedEntry()
selectedEntry.view().expand() if (selectedEntry instanceof DirectoryView)
selectedEntry.view().expand() if selectedEntry instanceof DirectoryView
collapseDirectory: ->
selectedEntry = @selectedEntry()
@@ -201,9 +201,9 @@ class TreeView extends ScrollView
openSelectedEntry: (changeFocus) ->
selectedEntry = @selectedEntry()
if (selectedEntry instanceof DirectoryView)
if selectedEntry instanceof DirectoryView
selectedEntry.view().toggleExpansion()
else if (selectedEntry instanceof FileView)
else if selectedEntry instanceof FileView
@rootView.open(selectedEntry.getPath(), { changeFocus })
moveSelectedEntry: ->
@@ -282,7 +282,7 @@ class TreeView extends ScrollView
entry.addClass('selected')
scrollToEntry: (entry) ->
displayElement = if (entry instanceof DirectoryView) then entry.header else entry
displayElement = if entry instanceof DirectoryView then entry.header else entry
top = @scrollTop() + displayElement.position().top
bottom = top + displayElement.outerHeight()