diff --git a/native/v8_extensions/git.mm b/native/v8_extensions/git.mm index 3f677454b..5ac5f23b7 100644 --- a/native/v8_extensions/git.mm +++ b/native/v8_extensions/git.mm @@ -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); diff --git a/spec/app/editor-spec.coffee b/spec/app/editor-spec.coffee index 355f234bd..0c7459a70 100644 --- a/spec/app/editor-spec.coffee +++ b/spec/app/editor-spec.coffee @@ -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' diff --git a/spec/app/status-bar-spec.coffee b/spec/app/status-bar-spec.coffee index a12af57b6..c3a4bc657 100644 --- a/spec/app/status-bar-spec.coffee +++ b/spec/app/status-bar-spec.coffee @@ -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('') diff --git a/src/app/editor.coffee b/src/app/editor.coffee index 4df684a78..019c4efd3 100644 --- a/src/app/editor.coffee +++ b/src/app/editor.coffee @@ -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 } diff --git a/src/app/git.coffee b/src/app/git.coffee index 6d29f1b53..ea4127744 100644 --- a/src/app/git.coffee +++ b/src/app/git.coffee @@ -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() diff --git a/src/app/status-bar.coffee b/src/app/status-bar.coffee index c3a368e91..556f9345d 100644 --- a/src/app/status-bar.coffee +++ b/src/app/status-bar.coffee @@ -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() diff --git a/src/extensions/outline-view/src/outline-view.coffee b/src/extensions/outline-view/src/outline-view.coffee index 22725703c..2b9b688ba 100644 --- a/src/extensions/outline-view/src/outline-view.coffee +++ b/src/extensions/outline-view/src/outline-view.coffee @@ -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('') diff --git a/src/extensions/tree-view/src/directory-view.coffee b/src/extensions/tree-view/src/directory-view.coffee index 2e09e7857..777395d1a 100644 --- a/src/extensions/tree-view/src/directory-view.coffee +++ b/src/extensions/tree-view/src/directory-view.coffee @@ -88,4 +88,3 @@ class DirectoryView extends View view = $(this).view() view.entryStates = childEntryStates view.expand() - diff --git a/src/extensions/tree-view/src/file-view.coffee b/src/extensions/tree-view/src/file-view.coffee index 850a9625a..6fb40540a 100644 --- a/src/extensions/tree-view/src/file-view.coffee +++ b/src/extensions/tree-view/src/file-view.coffee @@ -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 diff --git a/src/extensions/tree-view/src/tree-view.coffee b/src/extensions/tree-view/src/tree-view.coffee index c5d762650..03b06d40e 100644 --- a/src/extensions/tree-view/src/tree-view.coffee +++ b/src/extensions/tree-view/src/tree-view.coffee @@ -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()