mirror of
https://github.com/atom/atom.git
synced 2026-02-14 08:35:11 -05:00
Merge remote-tracking branch 'origin/dev' into markers
This commit is contained in:
@@ -3,7 +3,6 @@ _ = require 'underscore'
|
||||
EventEmitter = require 'event-emitter'
|
||||
|
||||
configDirPath = fs.absolute("~/.atom")
|
||||
configJsonPath = fs.join(configDirPath, "config.json")
|
||||
userInitScriptPath = fs.join(configDirPath, "user.coffee")
|
||||
bundledPackagesDirPath = fs.join(resourcePath, "src/packages")
|
||||
bundledThemesDirPath = fs.join(resourcePath, "themes")
|
||||
@@ -27,6 +26,8 @@ class Config
|
||||
core: _.clone(require('root-view').configDefaults)
|
||||
editor: _.clone(require('editor').configDefaults)
|
||||
@settings = {}
|
||||
@configFilePath = fs.resolve(configDirPath, 'config', ['json', 'cson'])
|
||||
@configFilePath ?= fs.join(configDirPath, 'config.cson')
|
||||
|
||||
load: ->
|
||||
@loadUserConfig()
|
||||
@@ -35,8 +36,8 @@ class Config
|
||||
atom.loadPackages()
|
||||
|
||||
loadUserConfig: ->
|
||||
if fs.exists(configJsonPath)
|
||||
userConfig = JSON.parse(fs.read(configJsonPath))
|
||||
if fs.exists(@configFilePath)
|
||||
userConfig = fs.readObject(@configFilePath)
|
||||
_.extend(@settings, userConfig)
|
||||
|
||||
get: (keyPath) ->
|
||||
@@ -77,7 +78,7 @@ class Config
|
||||
@trigger 'updated'
|
||||
|
||||
save: ->
|
||||
fs.write(configJsonPath, JSON.stringify(@settings, undefined, 2) + "\n")
|
||||
fs.writeObject(@configFilePath, @settings)
|
||||
|
||||
requireUserInitScript: ->
|
||||
try
|
||||
|
||||
@@ -4,7 +4,7 @@ SelectList = require 'select-list'
|
||||
module.exports =
|
||||
class GrammarView extends SelectList
|
||||
|
||||
@viewClass: -> "#{super} grammar-view"
|
||||
@viewClass: -> "#{super} grammar-view from-top overlay"
|
||||
|
||||
filterKey: 'name'
|
||||
|
||||
@@ -12,7 +12,6 @@ class GrammarView extends SelectList
|
||||
@currentGrammar = @editor.getGrammar()
|
||||
@path = @editor.getPath()
|
||||
@autoDetect = name: 'Auto Detect'
|
||||
requireStylesheet 'grammar-view.css'
|
||||
@command 'editor:select-grammar', =>
|
||||
@cancel()
|
||||
false
|
||||
|
||||
@@ -109,7 +109,7 @@ class SelectList extends View
|
||||
scrollToItem: (item) ->
|
||||
scrollTop = @list.scrollTop()
|
||||
desiredTop = item.position().top + scrollTop
|
||||
desiredBottom = desiredTop + item.height()
|
||||
desiredBottom = desiredTop + item.outerHeight()
|
||||
|
||||
if desiredTop < scrollTop
|
||||
@list.scrollTop(desiredTop)
|
||||
|
||||
@@ -29,7 +29,7 @@ windowAdditions =
|
||||
$(window).on 'core:close', => @close()
|
||||
$(window).command 'window:close', => @close()
|
||||
$(window).on 'focus', => $("body").addClass("is-focused")
|
||||
$(window).on 'focusout', => $("body").removeClass("is-focused")
|
||||
$(window).on 'blur', => $("body").removeClass("is-focused")
|
||||
|
||||
# This method is intended only to be run when starting a normal application
|
||||
# Note: RootView assigns itself on window on initialization so that
|
||||
@@ -114,6 +114,14 @@ window.startup()
|
||||
|
||||
requireStylesheet 'reset.css'
|
||||
requireStylesheet 'atom.css'
|
||||
requireStylesheet 'tabs.css'
|
||||
requireStylesheet 'tree-view.css'
|
||||
requireStylesheet 'status-bar.css'
|
||||
requireStylesheet 'command-panel.css'
|
||||
requireStylesheet 'fuzzy-finder.css'
|
||||
requireStylesheet 'overlay.css'
|
||||
requireStylesheet 'popover-list.css'
|
||||
requireStylesheet 'notification.css'
|
||||
|
||||
if nativeStylesheetPath = require.resolve("#{platform}.css")
|
||||
requireStylesheet(nativeStylesheetPath)
|
||||
|
||||
@@ -8,7 +8,7 @@ class AutocompleteView extends SelectList
|
||||
rootView.eachEditor (editor) ->
|
||||
new AutocompleteView(editor) if editor.attached and not editor.mini
|
||||
|
||||
@viewClass: -> "autocomplete #{super}"
|
||||
@viewClass: -> "autocomplete #{super} popover-list"
|
||||
|
||||
editor: null
|
||||
currentBuffer: null
|
||||
@@ -106,7 +106,6 @@ class AutocompleteView extends SelectList
|
||||
|
||||
setPosition: ->
|
||||
{ left, top } = @editor.pixelPositionForScreenPosition(@originalCursorPosition)
|
||||
|
||||
height = @outerHeight()
|
||||
potentialTop = top + @editor.lineHeight
|
||||
potentialBottom = potentialTop - @editor.scrollTop() + height
|
||||
|
||||
@@ -23,8 +23,8 @@ describe "CommandPalette", ->
|
||||
eventLi = palette.list.children("[data-event-name='#{eventName}']")
|
||||
if description
|
||||
expect(eventLi).toExist()
|
||||
expect(eventLi.find('.event-name')).toHaveText(eventName)
|
||||
expect(eventLi.find('.event-description')).toHaveText(description)
|
||||
expect(eventLi.find('.label')).toHaveText(description)
|
||||
expect(eventLi.find('.label').attr('title')).toBe(eventName)
|
||||
for binding in keyBindings[eventName] ? []
|
||||
expect(eventLi.find(".key-binding:contains(#{binding})")).toExist()
|
||||
else
|
||||
@@ -39,8 +39,8 @@ describe "CommandPalette", ->
|
||||
description = editorEvents[eventName] unless description
|
||||
if description
|
||||
expect(eventLi).toExist()
|
||||
expect(eventLi.find('.event-name')).toHaveText(eventName)
|
||||
expect(eventLi.find('.event-description')).toHaveText(description)
|
||||
expect(eventLi.find('.label')).toHaveText(description)
|
||||
expect(eventLi.find('.label').attr('title')).toBe(eventName)
|
||||
else
|
||||
expect(eventLi).not.toExist()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class CommandPaletteView extends SelectList
|
||||
@instance = new CommandPaletteView(rootView)
|
||||
|
||||
@viewClass: ->
|
||||
"#{super} command-palette"
|
||||
"#{super} command-palette overlay from-top"
|
||||
|
||||
filterKey: 'eventDescription'
|
||||
|
||||
@@ -41,12 +41,10 @@ class CommandPaletteView extends SelectList
|
||||
keyBindings = @keyBindings
|
||||
$$ ->
|
||||
@li class: 'event', 'data-event-name': eventName, =>
|
||||
@div eventDescription, class: 'event-description'
|
||||
@span eventDescription, class: 'label', title: eventName
|
||||
@div class: 'right', =>
|
||||
@div eventName, class: 'event-name'
|
||||
for binding in keyBindings[eventName] ? []
|
||||
@div binding, class: 'key-binding'
|
||||
@div class: 'clear-float'
|
||||
@kbd binding, class: 'key-binding'
|
||||
|
||||
confirmed: ({eventName}) ->
|
||||
@cancel()
|
||||
|
||||
@@ -408,7 +408,7 @@ describe "CommandPanel", ->
|
||||
|
||||
expect(previewList.scrollBottom()).toBeCloseTo previewList.prop('scrollHeight'), -1
|
||||
|
||||
previewList.trigger 'core:move-down'
|
||||
_.times previewList.getOperations().length, -> previewList.trigger 'core:move-up'
|
||||
expect(previewList.scrollTop()).toBe 0
|
||||
|
||||
it "doesn't bubble up the event and the command panel text doesn't change", ->
|
||||
|
||||
@@ -19,9 +19,9 @@ class FuzzyFinder extends DeferredAtomPackage
|
||||
new LoadPathsTask(rootView, callback).start()
|
||||
|
||||
onLoadEvent: (event, instance) ->
|
||||
if @projectPaths? and not @instance.projectPaths?
|
||||
@instance.projectPaths = @projectPaths
|
||||
@instance.reloadProjectPaths = false
|
||||
if @projectPaths? and not instance.projectPaths?
|
||||
instance.projectPaths = @projectPaths
|
||||
instance.reloadProjectPaths = false
|
||||
|
||||
switch event.type
|
||||
when 'fuzzy-finder:toggle-file-finder'
|
||||
|
||||
@@ -13,7 +13,7 @@ class FuzzyFinderView extends SelectList
|
||||
@instance = new FuzzyFinderView(rootView)
|
||||
|
||||
@viewClass: ->
|
||||
[super, 'fuzzy-finder'].join(' ')
|
||||
[super, 'fuzzy-finder', 'overlay', 'from-top'].join(' ')
|
||||
|
||||
allowActiveEditorChange: null
|
||||
maxItems: 10
|
||||
@@ -47,9 +47,9 @@ class FuzzyFinderView extends SelectList
|
||||
typeClass = 'pdf-name'
|
||||
else
|
||||
typeClass = 'text-name'
|
||||
@span fs.base(path), class: "file #{typeClass}"
|
||||
@span fs.base(path), class: "file label #{typeClass}"
|
||||
if folder = fs.directory(path)
|
||||
@span "- #{folder}/", class: 'directory'
|
||||
@span " - #{folder}/", class: 'directory'
|
||||
|
||||
openPath: (path) ->
|
||||
@rootView.open(path, {@allowActiveEditorChange}) if path
|
||||
|
||||
@@ -3,14 +3,13 @@ _ = require 'underscore'
|
||||
Git = require 'git'
|
||||
|
||||
module.exports =
|
||||
loadPaths: (rootPath, ignoredNames, ignoreGitIgnoredFiles) ->
|
||||
loadPaths: (rootPath, ignoredNames, excludeGitIgnoredPaths) ->
|
||||
paths = []
|
||||
repo = Git.open(rootPath, refreshIndexOnFocus: false) if ignoreGitIgnoredFiles
|
||||
repo = Git.open(rootPath, refreshIndexOnFocus: false) if excludeGitIgnoredPaths
|
||||
isIgnored = (path) ->
|
||||
for segment in path.split('/')
|
||||
return true if _.contains(ignoredNames, segment)
|
||||
return true if repo?.isPathIgnored(fs.join(rootPath, path))
|
||||
false
|
||||
repo?.isPathIgnored(fs.join(rootPath, path))
|
||||
onFile = (path) ->
|
||||
paths.push(path) unless isIgnored(path)
|
||||
onDirectory = (path) ->
|
||||
|
||||
@@ -6,11 +6,11 @@ class LoadPathsTask extends Task
|
||||
super('fuzzy-finder/src/load-paths-handler')
|
||||
|
||||
started: ->
|
||||
ignoredNames = config.get("fuzzyFinder.ignoredNames") ? []
|
||||
ignoredNames = ignoredNames.concat(config.get("core.ignoredNames") ? [])
|
||||
ignoreGitIgnoredFiles = config.get("core.hideGitIgnoredFiles")
|
||||
ignoredNames = config.get('fuzzyFinder.ignoredNames') ? []
|
||||
ignoredNames = ignoredNames.concat(config.get('core.ignoredNames') ? [])
|
||||
excludeGitIgnoredPaths = config.get('core.hideGitIgnoredFiles')
|
||||
rootPath = @rootView.project.getPath()
|
||||
@callWorkerMethod('loadPaths', rootPath, ignoredNames, ignoreGitIgnoredFiles)
|
||||
@callWorkerMethod('loadPaths', rootPath, ignoredNames, excludeGitIgnoredPaths)
|
||||
|
||||
pathsLoaded: (paths) ->
|
||||
@terminate()
|
||||
|
||||
@@ -22,10 +22,10 @@ class Gists
|
||||
success: (response) =>
|
||||
pasteboard.write(response.html_url)
|
||||
notification = $$ ->
|
||||
@div class: 'gist-notification', =>
|
||||
@div class: 'message-area', =>
|
||||
@span "Gist #{response.id} created", class: 'message'
|
||||
@br()
|
||||
@span "The url is on your clipboard", class: 'clipboard'
|
||||
@div class: 'notification', =>
|
||||
@span class: 'icon icon-gist mega-icon'
|
||||
@div class: 'content', =>
|
||||
@h3 "Gist #{response.id} created", class: 'title'
|
||||
@p "The url is on your clipboard", class: 'message'
|
||||
@rootView.append(notification.hide())
|
||||
notification.fadeIn().delay(2000).fadeOut(complete: -> $(this).remove())
|
||||
|
||||
@@ -44,8 +44,8 @@ describe "Gists package", ->
|
||||
expect(pasteboard.read()[0]).toBe 'https://gist.github.com/1'
|
||||
|
||||
it "flashes that the Gist was created", ->
|
||||
expect(rootView.find('.gist-notification')).toExist()
|
||||
expect(rootView.find('.gist-notification .message').text()).toBe 'Gist 1 created'
|
||||
expect(rootView.find('.notification')).toExist()
|
||||
expect(rootView.find('.notification .title').text()).toBe 'Gist 1 created'
|
||||
advanceClock(2000)
|
||||
expect(rootView.find('.gist-notification')).not.toExist()
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ class GoToLineView extends View
|
||||
@activate: (rootView) -> new GoToLineView(rootView)
|
||||
|
||||
@content: ->
|
||||
@div class: 'go-to-line', =>
|
||||
@div class: 'go-to-line overlay from-top mini', =>
|
||||
@subview 'miniEditor', new Editor(mini: true)
|
||||
@div class: 'message', outlet: 'message'
|
||||
|
||||
|
||||
@@ -30,9 +30,9 @@ describe "SymbolsView", ->
|
||||
expect(symbolsView.find('.loading')).toBeEmpty()
|
||||
expect(rootView.find('.symbols-view')).toExist()
|
||||
expect(symbolsView.list.children('li').length).toBe 2
|
||||
expect(symbolsView.list.children('li:first').find('.function-name')).toHaveText 'quicksort'
|
||||
expect(symbolsView.list.children('li:first').find('.label')).toHaveText 'quicksort'
|
||||
expect(symbolsView.list.children('li:first').find('.function-details')).toHaveText 'Line 1'
|
||||
expect(symbolsView.list.children('li:last').find('.function-name')).toHaveText 'quicksort.sort'
|
||||
expect(symbolsView.list.children('li:last').find('.label')).toHaveText 'quicksort.sort'
|
||||
expect(symbolsView.list.children('li:last').find('.function-details')).toHaveText 'Line 2'
|
||||
expect(symbolsView).not.toHaveClass "error"
|
||||
expect(symbolsView.error).not.toBeVisible()
|
||||
@@ -165,7 +165,7 @@ describe "SymbolsView", ->
|
||||
editor.setCursorBufferPosition([8,14])
|
||||
editor.trigger 'symbols-view:go-to-declaration'
|
||||
expect(symbolsView.list.children('li').length).toBe 1
|
||||
expect(symbolsView.list.children('li:first').find('.function-name')).toHaveText 'tagged.js'
|
||||
expect(symbolsView.list.children('li:first').find('.label')).toHaveText 'tagged.js'
|
||||
|
||||
describe "project symbols", ->
|
||||
it "displays all tags", ->
|
||||
@@ -181,9 +181,9 @@ describe "SymbolsView", ->
|
||||
expect(symbolsView.find('.loading')).toBeEmpty()
|
||||
expect(rootView.find('.symbols-view')).toExist()
|
||||
expect(symbolsView.list.children('li').length).toBe 4
|
||||
expect(symbolsView.list.children('li:first').find('.function-name')).toHaveText 'callMeMaybe'
|
||||
expect(symbolsView.list.children('li:first').find('.label')).toHaveText 'callMeMaybe'
|
||||
expect(symbolsView.list.children('li:first').find('.function-details')).toHaveText 'tagged.js'
|
||||
expect(symbolsView.list.children('li:last').find('.function-name')).toHaveText 'thisIsCrazy'
|
||||
expect(symbolsView.list.children('li:last').find('.label')).toHaveText 'thisIsCrazy'
|
||||
expect(symbolsView.list.children('li:last').find('.function-details')).toHaveText 'tagged.js'
|
||||
expect(symbolsView).not.toHaveClass "error"
|
||||
expect(symbolsView.error).not.toBeVisible()
|
||||
|
||||
@@ -12,7 +12,7 @@ class SymbolsView extends SelectList
|
||||
@activate: (rootView) ->
|
||||
@instance = new SymbolsView(rootView)
|
||||
|
||||
@viewClass: -> "#{super} symbols-view"
|
||||
@viewClass: -> "#{super} symbols-view overlay from-top"
|
||||
|
||||
filterKey: 'name'
|
||||
|
||||
@@ -22,14 +22,13 @@ class SymbolsView extends SelectList
|
||||
itemForElement: ({position, name, file}) ->
|
||||
$$ ->
|
||||
@li =>
|
||||
@div name, class: 'function-name'
|
||||
@div name, class: 'label'
|
||||
@div class: 'right', =>
|
||||
if position
|
||||
text = "Line #{position.row + 1}"
|
||||
else
|
||||
text = fs.base(file)
|
||||
@div text, class: 'function-details'
|
||||
@div class: 'clear-float'
|
||||
|
||||
toggleFileSymbols: ->
|
||||
if @hasParent()
|
||||
|
||||
@@ -38,6 +38,10 @@ describe "Tabs", ->
|
||||
expect(editor.getActiveEditSessionIndex()).toBe 1
|
||||
expect(tabs.find('.tab:eq(1)')).toHaveClass 'active'
|
||||
|
||||
it "sets the title on each tab to be the full path of the edit session", ->
|
||||
expect(tabs.find('.tab:eq(0) .file-name').attr('title')).toBe editor.editSessions[0].getPath()
|
||||
expect(tabs.find('.tab:eq(1) .file-name').attr('title')).toBe editor.editSessions[1].getPath()
|
||||
|
||||
describe "when the active edit session changes", ->
|
||||
it "highlights the tab for the newly-active edit session", ->
|
||||
editor.setActiveEditSessionIndex(0)
|
||||
@@ -60,6 +64,11 @@ describe "Tabs", ->
|
||||
expect(tabs.find('.tab').length).toBe 3
|
||||
expect(tabs.find('.tab:eq(2) .file-name').text()).toBe 'untitled'
|
||||
|
||||
it "removes the tab's title", ->
|
||||
rootView.open()
|
||||
expect(tabs.find('.tab').length).toBe 3
|
||||
expect(tabs.find('.tab:eq(2) .file-name').attr('title')).toBeUndefined()
|
||||
|
||||
describe "when an edit session is removed", ->
|
||||
it "removes the tab for the removed edit session", ->
|
||||
editor.setActiveEditSessionIndex(0)
|
||||
|
||||
@@ -28,7 +28,7 @@ module.exports =
|
||||
cson += @stringifyBoolean(value)
|
||||
else if _.isNumber(value)
|
||||
cson += @stringifyNumber(value)
|
||||
else if _.isNull(value)
|
||||
else if _.isNull(value) or value is undefined
|
||||
cson += @stringifyNull(value)
|
||||
else if _.isArray(value)
|
||||
cson += @stringifyArray(value, indentLevel + 2)
|
||||
|
||||
@@ -152,35 +152,33 @@ module.exports =
|
||||
undefined
|
||||
|
||||
isCompressedExtension: (ext) ->
|
||||
_.contains([
|
||||
_.indexOf([
|
||||
'.gz'
|
||||
'.jar'
|
||||
'.tar'
|
||||
'.zip'
|
||||
], ext)
|
||||
], ext, true) >= 0
|
||||
|
||||
isImageExtension: (ext) ->
|
||||
_.contains([
|
||||
_.indexOf([
|
||||
'.gif'
|
||||
'.jpeg'
|
||||
'.jpg'
|
||||
'.png'
|
||||
'.tiff'
|
||||
], ext)
|
||||
], ext, true) >= 0
|
||||
|
||||
isPdfExtension: (ext) ->
|
||||
_.contains([
|
||||
'.pdf'
|
||||
], ext)
|
||||
ext is '.pdf'
|
||||
|
||||
isMarkdownExtension: (ext) ->
|
||||
_.contains([
|
||||
_.indexOf([
|
||||
'.markdown'
|
||||
'.md'
|
||||
'.mkd'
|
||||
'.mkdown'
|
||||
'.ron'
|
||||
], ext)
|
||||
], ext, true) >= 0
|
||||
|
||||
readObject: (path) ->
|
||||
contents = @read(path)
|
||||
@@ -190,6 +188,14 @@ module.exports =
|
||||
else
|
||||
JSON.parse(contents)
|
||||
|
||||
writeObject: (path, object) ->
|
||||
if @extension(path) is '.cson'
|
||||
CSON = require 'cson'
|
||||
content = CSON.stringify(object)
|
||||
else
|
||||
content = JSON.stringify(object, undefined, 2)
|
||||
@write(path, "#{content}\n")
|
||||
|
||||
readPlist: (path) ->
|
||||
plist = require 'plist'
|
||||
object = null
|
||||
|
||||
@@ -12,6 +12,19 @@ self.console =
|
||||
log: -> callTaskMethod 'log', arguments...
|
||||
error: -> callTaskMethod 'error', arguments...
|
||||
|
||||
window.document =
|
||||
createElement: ->
|
||||
setAttribute: ->
|
||||
getElementsByTagName: -> []
|
||||
appendChild: ->
|
||||
documentElement:
|
||||
insertBefore: ->
|
||||
removeChild: ->
|
||||
getElementById: -> {}
|
||||
createComment: -> {}
|
||||
createDocumentFragment: -> {}
|
||||
self.document = window.document
|
||||
|
||||
# `callTaskMethod` can be used to invoke method's on the parent `Task` object
|
||||
# back in the window thread.
|
||||
self.callTaskMethod = (method, args...) ->
|
||||
@@ -19,9 +32,10 @@ self.callTaskMethod = (method, args...) ->
|
||||
|
||||
# The worker's initial handler replaces itself when `start` is invoked
|
||||
self.handler =
|
||||
start: ({resourcePath, requirePath, handlerPath}) ->
|
||||
self.resourcePath = resourcePath
|
||||
window.resourcePath = resourcePath
|
||||
start: ({resourcePath, globals, requirePath, handlerPath}) ->
|
||||
for key, value of globals
|
||||
self[key] = value
|
||||
window[key] = value
|
||||
importScripts(requirePath)
|
||||
require 'config'
|
||||
self.handler = require(handlerPath)
|
||||
|
||||
@@ -17,7 +17,10 @@ class Task
|
||||
|
||||
startWorker: ->
|
||||
@callWorkerMethod 'start'
|
||||
resourcePath: window.resourcePath
|
||||
globals:
|
||||
resourcePath: window.resourcePath
|
||||
navigator:
|
||||
userAgent: navigator.userAgent
|
||||
requirePath: require.getPath('require')
|
||||
handlerPath: @path
|
||||
|
||||
|
||||
Reference in New Issue
Block a user