mirror of
https://github.com/atom/atom.git
synced 2026-02-04 19:54:59 -05:00
Merge branch 'master' into tree-massage
This commit is contained in:
@@ -19,15 +19,15 @@ class StatusBar extends View
|
||||
|
||||
@content: ->
|
||||
@div class: 'status-bar', =>
|
||||
@div class: 'file-info', =>
|
||||
@span class: 'git-branch', outlet: 'branchArea', =>
|
||||
@span class: 'octicons branch-icon'
|
||||
@span class: 'branch-label', outlet: 'branchLabel'
|
||||
@span class: 'git-status', outlet: 'gitStatusIcon'
|
||||
@span class: 'file-info', =>
|
||||
@span class: 'current-path', outlet: 'currentPath'
|
||||
@span class: 'buffer-modified', outlet: 'bufferModified'
|
||||
@div class: 'cursor-position', =>
|
||||
@span outlet: 'gitStatusIcon'
|
||||
@span outlet: 'branchArea', =>
|
||||
@span class: 'octicons branch-icon'
|
||||
@span class: 'branch-label', outlet: 'branchLabel'
|
||||
@span outlet: 'cursorPosition'
|
||||
@span class: 'cursor-position', outlet: 'cursorPosition'
|
||||
|
||||
|
||||
initialize: (@rootView, @editor) ->
|
||||
@updatePathText()
|
||||
@@ -76,7 +76,7 @@ class StatusBar extends View
|
||||
@gitStatusIcon.empty()
|
||||
return unless path
|
||||
|
||||
@gitStatusIcon.removeClass().addClass('octicons')
|
||||
@gitStatusIcon.removeClass().addClass('git-status octicons')
|
||||
if @buffer.getGit()?.isPathModified(path)
|
||||
@gitStatusIcon.addClass('modified-status-icon')
|
||||
else if @buffer.getGit()?.isPathNew(path)
|
||||
|
||||
@@ -10,6 +10,7 @@ describe "WrapGuide", ->
|
||||
rootView.attachToDom()
|
||||
editor = rootView.getActiveEditor()
|
||||
wrapGuide = rootView.find('.wrap-guide').view()
|
||||
editor.width(editor.charWidth * wrapGuide.defaultColumn * 2)
|
||||
|
||||
afterEach ->
|
||||
rootView.deactivate()
|
||||
@@ -27,6 +28,7 @@ describe "WrapGuide", ->
|
||||
width = editor.charWidth * wrapGuide.defaultColumn
|
||||
expect(width).toBeGreaterThan(0)
|
||||
expect(wrapGuide.position().left).toBe(width)
|
||||
expect(wrapGuide).toBeVisible()
|
||||
|
||||
describe "when the font size changes", ->
|
||||
it "updates the wrap guide position", ->
|
||||
@@ -34,6 +36,7 @@ describe "WrapGuide", ->
|
||||
expect(initial).toBeGreaterThan(0)
|
||||
rootView.trigger('window:increase-font-size')
|
||||
expect(wrapGuide.position().left).toBeGreaterThan(initial)
|
||||
expect(wrapGuide).toBeVisible()
|
||||
|
||||
describe "overriding getGuideColumn", ->
|
||||
it "invokes the callback with the editor path", ->
|
||||
@@ -41,7 +44,7 @@ describe "WrapGuide", ->
|
||||
wrapGuide.getGuideColumn = (path) ->
|
||||
editorPath = path
|
||||
80
|
||||
wrapGuide.updateGuide(editor)
|
||||
wrapGuide.updateGuide()
|
||||
expect(editorPath).toBe(require.resolve('fixtures/sample.js'))
|
||||
|
||||
it "invokes the callback with a default value", ->
|
||||
@@ -51,7 +54,7 @@ describe "WrapGuide", ->
|
||||
column = defaultColumn
|
||||
defaultColumn
|
||||
|
||||
wrapGuide.updateGuide(editor)
|
||||
wrapGuide.updateGuide()
|
||||
expect(column).toBeGreaterThan(0)
|
||||
|
||||
# this is disabled because we no longer support passing config to an extension
|
||||
@@ -68,5 +71,11 @@ describe "WrapGuide", ->
|
||||
it "hides the guide when the column is less than 1", ->
|
||||
wrapGuide.getGuideColumn = (path) ->
|
||||
-1
|
||||
wrapGuide.updateGuide(editor)
|
||||
wrapGuide.updateGuide()
|
||||
expect(wrapGuide).toBeHidden()
|
||||
|
||||
describe "when no lines exceed the guide column and the editor width is smaller than the guide column position", ->
|
||||
it "hides the guide", ->
|
||||
editor.width(10)
|
||||
wrapGuide.updateGuide()
|
||||
expect(wrapGuide).toBeHidden()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
{View} = require 'space-pen'
|
||||
$ = require 'jquery'
|
||||
|
||||
module.exports =
|
||||
class WrapGuide extends View
|
||||
@@ -28,13 +29,18 @@ class WrapGuide extends View
|
||||
else
|
||||
@getGuideColumn = (path, defaultColumn) -> defaultColumn
|
||||
|
||||
@observeConfig 'editor.fontSize', => @updateGuide(@editor)
|
||||
@subscribe @editor, 'editor-path-change', => @updateGuide(@editor)
|
||||
@subscribe @editor, 'before-remove', => @rootView.off('.wrap-guide')
|
||||
@observeConfig 'editor.fontSize', => @updateGuide()
|
||||
@subscribe @editor, 'editor-path-change', => @updateGuide()
|
||||
@subscribe @editor, 'editor:min-width-changed', => @updateGuide()
|
||||
@subscribe $(window), 'resize', => @updateGuide()
|
||||
|
||||
updateGuide: (editor) ->
|
||||
column = @getGuideColumn(editor.getPath(), @defaultColumn)
|
||||
updateGuide: ->
|
||||
column = @getGuideColumn(@editor.getPath(), @defaultColumn)
|
||||
if column > 0
|
||||
@css('left', "#{editor.charWidth * column}px").show()
|
||||
columnWidth = @editor.charWidth * column
|
||||
if columnWidth < @editor.layerMinWidth or columnWidth < @editor.width()
|
||||
@css('left', "#{columnWidth}px").show()
|
||||
else
|
||||
@hide()
|
||||
else
|
||||
@hide()
|
||||
|
||||
Reference in New Issue
Block a user