mirror of
https://github.com/atom/atom.git
synced 2026-04-28 03:01:47 -04:00
Merge remote-tracking branch 'origin/master' into cj-text-buffer-cleanup
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
{View, $$, $$$} = require '../src/space-pen-extensions'
|
||||
{Document, Point, Range, Site} = require 'telepath'
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
@@ -7,9 +6,6 @@ _.nextTick = setImmediate
|
||||
|
||||
module.exports =
|
||||
_: _
|
||||
$: require '../src/jquery-extensions'
|
||||
$$: $$
|
||||
$$$: $$$
|
||||
BufferedNodeProcess: require '../src/buffered-node-process'
|
||||
BufferedProcess: require '../src/buffered-process'
|
||||
Directory: require '../src/directory'
|
||||
@@ -19,16 +15,20 @@ module.exports =
|
||||
Git: require '../src/git'
|
||||
Point: Point
|
||||
Range: Range
|
||||
ScrollView: require '../src/scroll-view'
|
||||
Site: Site
|
||||
stringscore: require '../vendor/stringscore'
|
||||
View: View
|
||||
|
||||
# The following classes can't be used from a Task handler and should therefore
|
||||
# only be exported when not running as a child node process
|
||||
unless process.env.ATOM_SHELL_INTERNAL_RUN_AS_NODE
|
||||
{$, $$, $$$, View} = require '../src/space-pen-extensions'
|
||||
|
||||
module.exports.$ = $
|
||||
module.exports.$$ = $$
|
||||
module.exports.$$$ = $$$
|
||||
module.exports.Editor = require '../src/editor'
|
||||
module.exports.pathForRepositoryUrl = require('../src/project').pathForRepositoryUrl
|
||||
module.exports.RootView = require '../src/root-view'
|
||||
module.exports.SelectList = require '../src/select-list'
|
||||
module.exports.ScrollView = require '../src/scroll-view'
|
||||
module.exports.Task = require '../src/task'
|
||||
module.exports.View = View
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
# FIXME Make jquery a package.json dependency
|
||||
# This is needed so that space-pen can be require it as 'jquery'
|
||||
module.exports = require '../vendor/jquery'
|
||||
15
package.json
15
package.json
@@ -9,7 +9,7 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/atom/atom/issues"
|
||||
},
|
||||
"atomShellVersion": "0.6.1",
|
||||
"atomShellVersion": "0.6.2",
|
||||
"dependencies": {
|
||||
"async": "0.2.6",
|
||||
"bootstrap": "git://github.com/twbs/bootstrap.git#v3.0.0",
|
||||
@@ -17,6 +17,7 @@
|
||||
"coffeestack": "0.6.0",
|
||||
"emissary": "0.6.0",
|
||||
"first-mate": "0.4.0",
|
||||
"fuzzaldrin": "0.1.0",
|
||||
"git-utils": "0.26.0",
|
||||
"guid": "0.0.10",
|
||||
"jasmine-focused": "~0.15.0",
|
||||
@@ -34,7 +35,7 @@
|
||||
"scandal": "0.5.0",
|
||||
"season": "0.13.0",
|
||||
"semver": "1.1.4",
|
||||
"space-pen": "1.3.0",
|
||||
"space-pen": "2.0.0",
|
||||
"telepath": "0.8.1",
|
||||
"temp": "0.5.0",
|
||||
"underscore-plus": "0.2.0",
|
||||
@@ -47,7 +48,7 @@
|
||||
"solarized-dark-syntax": "0.3.0",
|
||||
|
||||
"archive-view": "0.11.0",
|
||||
"autocomplete": "0.8.0",
|
||||
"autocomplete": "0.10.0",
|
||||
"autoflow": "0.4.0",
|
||||
"bookmarks": "0.7.0",
|
||||
"bracket-matcher": "0.7.0",
|
||||
@@ -58,7 +59,7 @@
|
||||
"editor-stats": "0.4.0",
|
||||
"exception-reporting": "0.4.0",
|
||||
"find-and-replace": "0.27.0",
|
||||
"fuzzy-finder": "0.13.0",
|
||||
"fuzzy-finder": "0.14.0",
|
||||
"gfm": "0.5.0",
|
||||
"git-diff": "0.11.0",
|
||||
"gists": "0.4.0",
|
||||
@@ -69,9 +70,9 @@
|
||||
"link": "0.6.0",
|
||||
"markdown-preview": "0.8.0",
|
||||
"metrics": "0.8.0",
|
||||
"package-generator": "0.11.0",
|
||||
"package-generator": "0.12.0",
|
||||
"release-notes": "0.4.0",
|
||||
"settings-view": "0.28.0",
|
||||
"settings-view": "0.29.0",
|
||||
"snippets": "0.9.0",
|
||||
"spell-check": "0.7.0",
|
||||
"status-bar": "0.14.0",
|
||||
@@ -82,7 +83,7 @@
|
||||
"timecop": "0.5.0",
|
||||
"to-the-hubs": "0.7.0",
|
||||
"toml": "0.3.0",
|
||||
"tree-view": "0.17.0",
|
||||
"tree-view": "0.18.0",
|
||||
"whitespace": "0.7.0",
|
||||
"wrap-guide": "0.4.0",
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
$ = require 'jquery'
|
||||
{View, $$} = require 'space-pen'
|
||||
{View, $, $$} = require '../src/space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
{convertStackTrace} = require 'coffeestack'
|
||||
|
||||
|
||||
6
spec/fixtures/jquery-task-handler.coffee
vendored
6
spec/fixtures/jquery-task-handler.coffee
vendored
@@ -1,6 +0,0 @@
|
||||
module.exports = ->
|
||||
try
|
||||
require 'jquery'
|
||||
true
|
||||
catch e
|
||||
false
|
||||
@@ -1,178 +0,0 @@
|
||||
{_, $, $$, View} = require 'atom'
|
||||
|
||||
describe 'jQuery extensions', ->
|
||||
describe '$.fn.preempt(eventName, handler)', ->
|
||||
[returnValue, element, events] = []
|
||||
|
||||
beforeEach ->
|
||||
returnValue = undefined
|
||||
element = $("<div>")
|
||||
events = []
|
||||
|
||||
element.on 'foo', -> events.push(1)
|
||||
element.preempt 'foo', ->
|
||||
events.push(2)
|
||||
returnValue
|
||||
element.on 'foo', -> events.push(3)
|
||||
|
||||
it 'calls the preempting handler before all others', ->
|
||||
element.trigger 'foo'
|
||||
expect(events).toEqual [2,1,3]
|
||||
|
||||
describe 'when handler returns false', ->
|
||||
it 'does not call subsequent handlers', ->
|
||||
returnValue = false
|
||||
element.trigger 'foo'
|
||||
expect(events).toEqual [2]
|
||||
|
||||
describe 'when the event is namespaced', ->
|
||||
it 'calls handler', ->
|
||||
element.preempt 'foo.bar', -> events.push(4)
|
||||
element.trigger 'foo'
|
||||
expect(events).toEqual [4,2,1,3]
|
||||
|
||||
events = []
|
||||
element.trigger 'foo.bar'
|
||||
expect(events).toEqual [4]
|
||||
|
||||
events = []
|
||||
element.off('.bar')
|
||||
element.trigger 'foo'
|
||||
expect(events).toEqual [2,1,3]
|
||||
|
||||
describe "$.fn.events() and $.fn.document(...)", ->
|
||||
it "returns a list of all events being listened for on the target node or its ancestors, along with their documentation string", ->
|
||||
view = $$ ->
|
||||
@div id: 'a', =>
|
||||
@div id: 'b', =>
|
||||
@div id: 'c'
|
||||
@div id: 'd'
|
||||
|
||||
view.document 'a1', "This is event A2"
|
||||
view.document 'b2', "This is event b2"
|
||||
|
||||
view.document 'a1', "A1: Waste perfectly-good steak"
|
||||
view.on 'a1', ->
|
||||
view.on 'a2', ->
|
||||
view.on 'b1', -> # should not appear as a duplicate
|
||||
|
||||
divB = view.find('#b')
|
||||
|
||||
divB.document 'b1', "B1: Super-sonic bomber"
|
||||
divB.document 'b2', "B2: Looks evil. Kinda is."
|
||||
divB.on 'b1', ->
|
||||
divB.on 'b2', ->
|
||||
|
||||
view.find('#c').on 'c', ->
|
||||
view.find('#d').on 'd', ->
|
||||
|
||||
expect(view.find('#c').events()).toEqual
|
||||
'c': null
|
||||
'b1': "B1: Super-sonic bomber"
|
||||
'b2': "B2: Looks evil. Kinda is."
|
||||
'a1': "A1: Waste perfectly-good steak"
|
||||
'a2': null
|
||||
|
||||
describe "$.fn.command(eventName, [selector, options,] handler)", ->
|
||||
[view, handler] = []
|
||||
|
||||
beforeEach ->
|
||||
view = $$ ->
|
||||
@div class: 'a', =>
|
||||
@div class: 'b'
|
||||
@div class: 'c'
|
||||
handler = jasmine.createSpy("commandHandler")
|
||||
|
||||
it "binds the handler to the given event / selector for all argument combinations", ->
|
||||
view.command 'test:foo', handler
|
||||
view.trigger 'test:foo'
|
||||
expect(handler).toHaveBeenCalled()
|
||||
handler.reset()
|
||||
|
||||
view.command 'test:bar', '.b', handler
|
||||
view.find('.b').trigger 'test:bar'
|
||||
view.find('.c').trigger 'test:bar'
|
||||
expect(handler.callCount).toBe 1
|
||||
handler.reset()
|
||||
|
||||
view.command 'test:baz', doc: 'Spaz', handler
|
||||
view.trigger 'test:baz'
|
||||
expect(handler).toHaveBeenCalled()
|
||||
handler.reset()
|
||||
|
||||
view.command 'test:quux', '.c', doc: 'Lorem', handler
|
||||
view.find('.b').trigger 'test:quux'
|
||||
view.find('.c').trigger 'test:quux'
|
||||
expect(handler.callCount).toBe 1
|
||||
|
||||
it "passes the 'data' option through when binding the event handler", ->
|
||||
view.command 'test:foo', data: "bar", handler
|
||||
view.trigger 'test:foo'
|
||||
expect(handler.argsForCall[0][0].data).toBe 'bar'
|
||||
|
||||
it "sets a custom docstring if the 'doc' option is specified", ->
|
||||
view.command 'test:foo', doc: "Foo!", handler
|
||||
expect(view.events()).toEqual 'test:foo': 'Test: Foo!'
|
||||
|
||||
it "capitalizes the 'github' prefix how we like it", ->
|
||||
view.command 'github:spelling', handler
|
||||
expect(view.events()).toEqual 'github:spelling': 'GitHub: Spelling'
|
||||
|
||||
describe "$.fn.scrollUp/Down/ToTop/ToBottom", ->
|
||||
it "scrolls the element in the specified way if possible", ->
|
||||
view = $$ -> @div => _.times 20, => @div('A')
|
||||
view.css(height: 100, width: 100, overflow: 'scroll')
|
||||
view.attachToDom()
|
||||
|
||||
view.scrollUp()
|
||||
expect(view.scrollTop()).toBe 0
|
||||
|
||||
view.scrollDown()
|
||||
expect(view.scrollTop()).toBeGreaterThan 0
|
||||
previousScrollTop = view.scrollTop()
|
||||
view.scrollDown()
|
||||
expect(view.scrollTop()).toBeGreaterThan previousScrollTop
|
||||
|
||||
view.scrollToBottom()
|
||||
expect(view.scrollTop()).toBe view.prop('scrollHeight') - 100
|
||||
previousScrollTop = view.scrollTop()
|
||||
view.scrollDown()
|
||||
expect(view.scrollTop()).toBe previousScrollTop
|
||||
view.scrollUp()
|
||||
expect(view.scrollTop()).toBeLessThan previousScrollTop
|
||||
previousScrollTop = view.scrollTop()
|
||||
view.scrollUp()
|
||||
expect(view.scrollTop()).toBeLessThan previousScrollTop
|
||||
|
||||
view.scrollToTop()
|
||||
expect(view.scrollTop()).toBe 0
|
||||
|
||||
describe "Event.prototype", ->
|
||||
class GrandchildView extends View
|
||||
@content: -> @div class: 'grandchild'
|
||||
|
||||
class ChildView extends View
|
||||
@content: ->
|
||||
@div class: 'child', =>
|
||||
@subview 'grandchild', new GrandchildView
|
||||
|
||||
class ParentView extends View
|
||||
@content: ->
|
||||
@div class: 'parent', =>
|
||||
@subview 'child', new ChildView
|
||||
|
||||
[parentView, event] = []
|
||||
beforeEach ->
|
||||
parentView = new ParentView
|
||||
eventHandler = jasmine.createSpy('eventHandler')
|
||||
parentView.on 'foo', '.child', eventHandler
|
||||
parentView.child.grandchild.trigger 'foo'
|
||||
event = eventHandler.argsForCall[0][0]
|
||||
|
||||
describe ".currentTargetView()", ->
|
||||
it "returns the current target's space pen view", ->
|
||||
expect(event.currentTargetView()).toBe parentView.child
|
||||
|
||||
describe ".targetView()", ->
|
||||
it "returns the target's space pen view", ->
|
||||
expect(event.targetView()).toBe parentView.child.grandchild
|
||||
@@ -36,7 +36,7 @@ describe "Pane", ->
|
||||
expect(pane.activeItem).toBe view1
|
||||
pane.showItem(view2)
|
||||
expect(view1.css('display')).toBe 'none'
|
||||
expect(view2.css('display')).toBe ''
|
||||
expect(view2.css('display')).not.toBe 'none'
|
||||
expect(pane.activeItem).toBe view2
|
||||
|
||||
it "triggers 'pane:active-item-changed' if the item isn't already the activeItem", ->
|
||||
@@ -90,7 +90,7 @@ describe "Pane", ->
|
||||
it "appends and shows a view to display the item based on its `.getViewClass` method", ->
|
||||
pane.showItem(editSession1)
|
||||
editor = pane.activeView
|
||||
expect(editor.css('display')).toBe ''
|
||||
expect(editor.css('display')).not.toBe 'none'
|
||||
expect(editor.activeEditSession).toBe editSession1
|
||||
|
||||
describe "when a valid view has already been appended for another item", ->
|
||||
@@ -99,7 +99,7 @@ describe "Pane", ->
|
||||
pane.showItem(editSession2)
|
||||
expect(pane.itemViews.find('.editor').length).toBe 2
|
||||
editor = pane.activeView
|
||||
expect(editor.css('display')).toBe ''
|
||||
expect(editor.css('display')).not.toBe 'none'
|
||||
expect(editor.activeEditSession).toBe editSession2
|
||||
|
||||
it "creates a new view with the item", ->
|
||||
@@ -498,6 +498,9 @@ describe "Pane", ->
|
||||
expect(pane2.getNextPane()).toBe pane
|
||||
|
||||
describe "when the pane is focused", ->
|
||||
beforeEach ->
|
||||
container.attachToDom()
|
||||
|
||||
it "focuses the active item view", ->
|
||||
focusHandler = jasmine.createSpy("focusHandler")
|
||||
pane.activeItem.on 'focus', focusHandler
|
||||
|
||||
@@ -92,6 +92,9 @@ describe "RootView", ->
|
||||
expect(rootView.getEditors().length).toBe 0
|
||||
|
||||
describe "focus", ->
|
||||
beforeEach ->
|
||||
rootView.attachToDom()
|
||||
|
||||
describe "when there is an active view", ->
|
||||
it "hands off focus to the active view", ->
|
||||
editor = rootView.getActiveView()
|
||||
|
||||
@@ -160,7 +160,7 @@ describe "SelectList", ->
|
||||
describe "when the mini editor loses focus", ->
|
||||
it "triggers the cancelled hook and detaches the select list", ->
|
||||
spyOn(selectList, 'detach')
|
||||
miniEditor.trigger 'focusout'
|
||||
miniEditor.hiddenInput.trigger 'focusout'
|
||||
expect(selectList.cancelled).toHaveBeenCalled()
|
||||
expect(selectList.detach).toHaveBeenCalled()
|
||||
|
||||
|
||||
@@ -8,10 +8,7 @@ try
|
||||
document.title = "Spec Suite"
|
||||
runSpecSuite './spec-suite'
|
||||
catch error
|
||||
unless atom.getLoadSettings().exitWhenDone
|
||||
atom.getCurrentWindow().setSize(800, 600)
|
||||
atom.getCurrentWindow().center()
|
||||
atom.openDevTools()
|
||||
|
||||
console.error(error.stack ? error)
|
||||
atom.exit(1) if atom.getLoadSettings().exitWhenDone
|
||||
if atom?.getLoadSettings().exitWhenDone
|
||||
atom.exit(1)
|
||||
else
|
||||
throw error
|
||||
|
||||
@@ -1,26 +1,6 @@
|
||||
Task = require '../src/task'
|
||||
|
||||
describe "Task", ->
|
||||
describe "populating the window with fake properties", ->
|
||||
describe "when jQuery is loaded in a child process", ->
|
||||
it "doesn't log to the console", ->
|
||||
spyOn(console, 'log')
|
||||
spyOn(console, 'error')
|
||||
spyOn(console, 'warn')
|
||||
|
||||
jqueryTask = new Task(require.resolve('./fixtures/jquery-task-handler'))
|
||||
jqueryLoaded = false
|
||||
jqueryTask.start (loaded) -> jqueryLoaded = loaded
|
||||
|
||||
waitsFor "child process to start and jquery to be required", 5000, ->
|
||||
jqueryLoaded
|
||||
|
||||
runs ->
|
||||
expect(jqueryLoaded).toBeTruthy()
|
||||
expect(console.log).not.toHaveBeenCalled()
|
||||
expect(console.error).not.toHaveBeenCalled()
|
||||
expect(console.warn).not.toHaveBeenCalled()
|
||||
|
||||
describe "@once(taskPath, args..., callback)", ->
|
||||
it "terminates the process after it completes", ->
|
||||
handlerResult = null
|
||||
|
||||
@@ -24,7 +24,7 @@ describe "Window", ->
|
||||
|
||||
describe "when the window is blurred", ->
|
||||
beforeEach ->
|
||||
$(window).trigger 'blur'
|
||||
$(window).triggerHandler 'blur'
|
||||
|
||||
afterEach ->
|
||||
$('body').removeClass('is-blurred')
|
||||
@@ -34,7 +34,7 @@ describe "Window", ->
|
||||
|
||||
describe "when the window is focused again", ->
|
||||
it "removes the .is-blurred class from the body", ->
|
||||
$(window).trigger 'focus'
|
||||
$(window).triggerHandler 'focus'
|
||||
expect($("body")).not.toHaveClass("is-blurred")
|
||||
|
||||
describe "window:close event", ->
|
||||
@@ -52,13 +52,18 @@ describe "Window", ->
|
||||
expect(beforeunload).toHaveBeenCalled()
|
||||
|
||||
describe "beforeunload event", ->
|
||||
[beforeUnloadEvent] = []
|
||||
|
||||
beforeEach ->
|
||||
beforeUnloadEvent = $.Event(new Event('beforeunload'))
|
||||
|
||||
describe "when pane items are are modified", ->
|
||||
it "prompts user to save and and calls rootView.confirmClose", ->
|
||||
spyOn(rootView, 'confirmClose').andCallThrough()
|
||||
spyOn(atom, "confirmSync").andReturn(2)
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
$(window).trigger 'beforeunload'
|
||||
$(window).trigger(beforeUnloadEvent)
|
||||
expect(rootView.confirmClose).toHaveBeenCalled()
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
@@ -66,14 +71,14 @@ describe "Window", ->
|
||||
spyOn(atom, "confirmSync").andReturn(2)
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
expect(window.onbeforeunload(new Event('beforeunload'))).toBeTruthy()
|
||||
$(window).trigger(beforeUnloadEvent)
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
it "prompts user to save and handler returns false if dialog is canceled", ->
|
||||
spyOn(atom, "confirmSync").andReturn(1)
|
||||
editSession = rootView.openSync("sample.js")
|
||||
editSession.insertText("I look different, I feel different.")
|
||||
expect(window.onbeforeunload(new Event('beforeunload'))).toBeFalsy()
|
||||
$(window).trigger(beforeUnloadEvent)
|
||||
expect(atom.confirmSync).toHaveBeenCalled()
|
||||
|
||||
describe ".unloadEditorWindow()", ->
|
||||
|
||||
@@ -3,7 +3,7 @@ Package = require './package'
|
||||
fsUtils = require './fs-utils'
|
||||
path = require 'path'
|
||||
_ = require 'underscore-plus'
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
CSON = require 'season'
|
||||
{Emitter} = require 'emissary'
|
||||
|
||||
@@ -236,7 +236,7 @@ class AtomPackage extends Package
|
||||
disabledHandler = ->
|
||||
element = $(event.target)
|
||||
while element.length
|
||||
if eventHandlers = element.data('events')?[event.type]
|
||||
if eventHandlers = element.handlers()?[event.type]
|
||||
for eventHandler in eventHandlers
|
||||
eventHandler.disabledHandler = eventHandler.handler
|
||||
eventHandler.handler = disabledHandler
|
||||
|
||||
@@ -5,7 +5,7 @@ Emitter::trigger = (args...) -> @emit(args...)
|
||||
Emitter::subscriptionCount = (args...) -> @getSubscriptionCount(args...)
|
||||
|
||||
fsUtils = require './fs-utils'
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
Package = require './package'
|
||||
ipc = require 'ipc'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
fsUtils = require './fs-utils'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$ = require 'jquery'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
remote = require 'remote'
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@ class CursorView extends View
|
||||
pixelPosition = @getPixelPosition()
|
||||
|
||||
unless _.isEqual(@lastPixelPosition, pixelPosition)
|
||||
changedPosition = true
|
||||
@lastPixelPosition = pixelPosition
|
||||
@css(pixelPosition)
|
||||
@trigger 'cursor:moved'
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{View, $$} = require './space-pen-extensions'
|
||||
{View, $, $$} = require './space-pen-extensions'
|
||||
TextBuffer = require './text-buffer'
|
||||
Gutter = require './gutter'
|
||||
{Point, Range} = require 'telepath'
|
||||
@@ -6,7 +6,6 @@ EditSession = require './edit-session'
|
||||
CursorView = require './cursor-view'
|
||||
SelectionView = require './selection-view'
|
||||
fsUtils = require './fs-utils'
|
||||
$ = require './jquery-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
MeasureRange = document.createRange()
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
stringScore = require '../vendor/stringscore'
|
||||
path = require 'path'
|
||||
|
||||
module.exports = (candidates, query, options={}) ->
|
||||
if query
|
||||
scoredCandidates = candidates.map (candidate) ->
|
||||
string = if options.key? then candidate[options.key] else candidate
|
||||
score = stringScore(string, query)
|
||||
|
||||
unless /\//.test(query)
|
||||
# Basename matches count for more.
|
||||
score += stringScore(path.basename(string), query)
|
||||
|
||||
# Shallow files are scored higher
|
||||
depth = Math.max(1, 10 - string.split('/').length - 1)
|
||||
score *= depth * 0.01
|
||||
|
||||
{ candidate, score }
|
||||
|
||||
scoredCandidates.sort (a, b) ->
|
||||
if a.score > b.score then -1
|
||||
else if a.score < b.score then 1
|
||||
else 0
|
||||
candidates = (scoredCandidate.candidate for scoredCandidate in scoredCandidates when scoredCandidate.score > 0)
|
||||
|
||||
candidates = candidates[0...options.maxResults] if options.maxResults?
|
||||
candidates
|
||||
@@ -65,7 +65,7 @@ class Git
|
||||
|
||||
refreshOnWindowFocus ?= true
|
||||
if refreshOnWindowFocus
|
||||
$ = require 'jquery'
|
||||
{$} = require './space-pen-extensions'
|
||||
@subscribe $(window), 'focus', =>
|
||||
@refreshIndex()
|
||||
@refreshStatus()
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{View, $$, $$$} = require './space-pen-extensions'
|
||||
{View, $, $$, $$$} = require './space-pen-extensions'
|
||||
{Range} = require 'telepath'
|
||||
$ = require './jquery-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
# Private: Represents the portion of the {Editor} containing row numbers.
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
$ = require '../vendor/jquery'
|
||||
_ = require 'underscore-plus'
|
||||
|
||||
$.fn.scrollBottom = (newValue) ->
|
||||
if newValue?
|
||||
@scrollTop(newValue - @height())
|
||||
else
|
||||
@scrollTop() + @height()
|
||||
|
||||
$.fn.scrollDown = ->
|
||||
@scrollTop(@scrollTop() + $(window).height() / 20)
|
||||
|
||||
$.fn.scrollUp = ->
|
||||
@scrollTop(@scrollTop() - $(window).height() / 20)
|
||||
|
||||
$.fn.scrollToTop = ->
|
||||
@scrollTop(0)
|
||||
|
||||
$.fn.scrollToBottom = ->
|
||||
@scrollTop(@prop('scrollHeight'))
|
||||
|
||||
$.fn.scrollRight = (newValue) ->
|
||||
if newValue?
|
||||
@scrollLeft(newValue - @width())
|
||||
else
|
||||
@scrollLeft() + @width()
|
||||
|
||||
$.fn.pageUp = ->
|
||||
@scrollTop(@scrollTop() - @height())
|
||||
|
||||
$.fn.pageDown = ->
|
||||
@scrollTop(@scrollTop() + @height())
|
||||
|
||||
$.fn.isOnDom = ->
|
||||
@closest(document.body).length is 1
|
||||
|
||||
$.fn.isVisible = ->
|
||||
!@isHidden()
|
||||
|
||||
$.fn.isHidden = ->
|
||||
# We used to check @is(':hidden'). But this is much faster than the
|
||||
# offsetWidth/offsetHeight check + all the pseudo selector mess in jquery.
|
||||
style = this[0].style
|
||||
|
||||
if style.display == 'none' or not @isOnDom()
|
||||
true
|
||||
else if style.display
|
||||
false
|
||||
else
|
||||
getComputedStyle(this[0]).display == 'none'
|
||||
|
||||
$.fn.isDisabled = ->
|
||||
!!@attr('disabled')
|
||||
|
||||
$.fn.enable = ->
|
||||
@removeAttr('disabled')
|
||||
|
||||
$.fn.disable = ->
|
||||
@attr('disabled', 'disabled')
|
||||
|
||||
$.fn.insertAt = (index, element) ->
|
||||
target = @children(":eq(#{index})")
|
||||
if target.length
|
||||
$(element).insertBefore(target)
|
||||
else
|
||||
@append(element)
|
||||
|
||||
$.fn.removeAt = (index) ->
|
||||
@children(":eq(#{index})").remove()
|
||||
|
||||
$.fn.indexOf = (child) ->
|
||||
@children().toArray().indexOf($(child)[0])
|
||||
|
||||
$.fn.containsElement = (element) ->
|
||||
(element[0].compareDocumentPosition(this[0]) & 8) == 8
|
||||
|
||||
$.fn.preempt = (eventName, handler) ->
|
||||
@on eventName, (e, args...) ->
|
||||
if handler(e, args...) == false then e.stopImmediatePropagation()
|
||||
|
||||
eventNameWithoutNamespace = eventName.split('.')[0]
|
||||
handlers = @data('events')[eventNameWithoutNamespace]
|
||||
handlers.unshift(handlers.pop())
|
||||
|
||||
$.fn.hasParent = ->
|
||||
@parent()[0]?
|
||||
|
||||
$.fn.flashError = ->
|
||||
@addClass 'error'
|
||||
removeErrorClass = => @removeClass 'error'
|
||||
window.setTimeout(removeErrorClass, 300)
|
||||
|
||||
$.fn.trueHeight = ->
|
||||
this[0].getBoundingClientRect().height
|
||||
|
||||
$.fn.trueWidth = ->
|
||||
this[0].getBoundingClientRect().width
|
||||
|
||||
$.fn.document = (eventName, docString) ->
|
||||
eventDescriptions = {}
|
||||
eventDescriptions[eventName] = docString
|
||||
@data('documentation', {}) unless @data('documentation')
|
||||
_.extend(@data('documentation'), eventDescriptions)
|
||||
|
||||
$.fn.events = ->
|
||||
documentation = @data('documentation') ? {}
|
||||
events = {}
|
||||
|
||||
for eventName of @data('events') ? {}
|
||||
events[eventName] = documentation[eventName] ? null
|
||||
|
||||
if @hasParent()
|
||||
_.extend(@parent().events(), events)
|
||||
else
|
||||
events
|
||||
|
||||
$.fn.command = (eventName, selector, options, handler) ->
|
||||
if not options?
|
||||
handler = selector
|
||||
selector = null
|
||||
else if not handler?
|
||||
handler = options
|
||||
options = null
|
||||
|
||||
if selector? and typeof(selector) is 'object'
|
||||
options = selector
|
||||
selector = null
|
||||
|
||||
@document(eventName, _.humanizeEventName(eventName, options?["doc"]))
|
||||
@on(eventName, selector, options?['data'], handler)
|
||||
|
||||
$.fn.iconSize = (size) ->
|
||||
@width(size).height(size).css('font-size', size)
|
||||
|
||||
$.fn.intValue = ->
|
||||
parseInt(@text())
|
||||
|
||||
$.Event.prototype.abortKeyBinding = ->
|
||||
$.Event.prototype.currentTargetView = -> $(this.currentTarget).view()
|
||||
$.Event.prototype.targetView = -> $(this.target).view()
|
||||
|
||||
module.exports = $
|
||||
@@ -1,4 +1,4 @@
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
fsUtils = require './fs-utils'
|
||||
path = require 'path'
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
$ = require './jquery-extensions'
|
||||
{View} = require './space-pen-extensions'
|
||||
{$, View} = require './space-pen-extensions'
|
||||
telepath = require 'telepath'
|
||||
|
||||
### Internal ###
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
PaneAxis = require './pane-axis'
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{View} = require './space-pen-extensions'
|
||||
{$, View} = require './space-pen-extensions'
|
||||
Pane = require './pane'
|
||||
$ = require './jquery-extensions'
|
||||
telepath = require 'telepath'
|
||||
|
||||
# Private: Manages the list of panes within a {RootView}
|
||||
@@ -114,7 +113,8 @@ class PaneContainer extends View
|
||||
@empty()
|
||||
if root?
|
||||
@append(root)
|
||||
@itemAdded(root.activeItem) if root.activeItem
|
||||
@itemAdded(root.activeItem) if root.activeItem?
|
||||
root.makeActive?()
|
||||
@state.set(root: root?.getState())
|
||||
|
||||
removeChild: (child) ->
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
PaneAxis = require './pane-axis'
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
{dirname} = require 'path'
|
||||
{View} = require './space-pen-extensions'
|
||||
$ = require './jquery-extensions'
|
||||
{$, View} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
telepath = require 'telepath'
|
||||
PaneRow = require './pane-row'
|
||||
@@ -18,7 +17,7 @@ class Pane extends View
|
||||
@acceptsDocuments: true
|
||||
|
||||
@content: (wrappedView) ->
|
||||
@div class: 'pane', =>
|
||||
@div class: 'pane', tabindex: -1, =>
|
||||
@div class: 'item-views', outlet: 'itemViews'
|
||||
|
||||
@deserialize: (state) ->
|
||||
@@ -94,7 +93,6 @@ class Pane extends View
|
||||
@attached = true
|
||||
@trigger 'pane:attached', [this]
|
||||
|
||||
|
||||
# Public: Focus this pane.
|
||||
makeActive: ->
|
||||
wasActive = @isActive()
|
||||
@@ -169,7 +167,7 @@ class Pane extends View
|
||||
view = @viewForItem(item)
|
||||
@itemViews.children().not(view).hide()
|
||||
@itemViews.append(view) unless view.parent().is(@itemViews)
|
||||
view.show()
|
||||
view.show() if @attached
|
||||
view.focus() if isFocused
|
||||
@activeItem = item
|
||||
@activeView = view
|
||||
@@ -414,6 +412,7 @@ class Pane extends View
|
||||
when 'before' then parent.insertChildBefore(this, newPane)
|
||||
when 'after' then parent.insertChildAfter(this, newPane)
|
||||
@getContainer().adjustPaneDimensions()
|
||||
newPane.makeActive()
|
||||
newPane.focus()
|
||||
newPane
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ fs = require 'fs'
|
||||
ipc = require 'ipc'
|
||||
path = require 'path'
|
||||
Q = require 'q'
|
||||
$ = require './jquery-extensions'
|
||||
{$$, View} = require './space-pen-extensions'
|
||||
{$, $$, View} = require './space-pen-extensions'
|
||||
fsUtils = require './fs-utils'
|
||||
_ = require 'underscore-plus'
|
||||
telepath = require 'telepath'
|
||||
@@ -56,7 +55,7 @@ class RootView extends View
|
||||
|
||||
# Private:
|
||||
@content: (state) ->
|
||||
@div id: 'root-view', =>
|
||||
@div id: 'root-view', tabindex: -1, =>
|
||||
@div id: 'horizontal', outlet: 'horizontal', =>
|
||||
@div id: 'vertical', outlet: 'vertical', =>
|
||||
@div outlet: 'panes'
|
||||
@@ -154,6 +153,7 @@ class RootView extends View
|
||||
focusableChild.focus()
|
||||
false
|
||||
else
|
||||
$(document.body).focus()
|
||||
true
|
||||
|
||||
# Private:
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
$ = require './jquery-extensions'
|
||||
{ View } = require './space-pen-extensions'
|
||||
{$, View} = require './space-pen-extensions'
|
||||
Editor = require './editor'
|
||||
fuzzyFilter = require './fuzzy-filter'
|
||||
fuzzyFilter = require('fuzzaldrin').filter
|
||||
|
||||
# Public: Provides a widget for users to make a selection from a list of
|
||||
# choices.
|
||||
@@ -29,7 +28,7 @@ class SelectList extends View
|
||||
# Public:
|
||||
initialize: ->
|
||||
@miniEditor.getBuffer().on 'changed', => @schedulePopulateList()
|
||||
@miniEditor.on 'focusout', => @cancel() unless @cancelling
|
||||
@miniEditor.hiddenInput.on 'focusout', => @cancel() unless @cancelling
|
||||
@on 'core:move-up', => @selectPreviousItem()
|
||||
@on 'core:move-down', => @selectNextItem()
|
||||
@on 'core:move-to-top', =>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
_ = require 'underscore-plus'
|
||||
spacePen = require 'space-pen'
|
||||
jQuery = require './jquery-extensions'
|
||||
ConfigObserver = require './config-observer'
|
||||
{Subscriber} = require 'emissary'
|
||||
|
||||
_.extend spacePen.View.prototype, ConfigObserver
|
||||
Subscriber.includeInto(spacePen.View)
|
||||
|
||||
jQuery = spacePen.jQuery
|
||||
originalCleanData = jQuery.cleanData
|
||||
jQuery.cleanData = (elements) ->
|
||||
for element in elements
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
_ = require 'underscore-plus'
|
||||
jQuery = require './jquery-extensions'
|
||||
Specificity = require '../vendor/specificity'
|
||||
{$$} = require './space-pen-extensions'
|
||||
{$, $$} = require './space-pen-extensions'
|
||||
fsUtils = require './fs-utils'
|
||||
{Emitter} = require 'emissary'
|
||||
NullGrammar = require './null-grammar'
|
||||
@@ -107,7 +106,7 @@ class Syntax
|
||||
|
||||
matchingPropertiesForElement: (element, candidates) ->
|
||||
matchingScopedProperties = candidates.filter ({selector}) ->
|
||||
jQuery.find.matchesSelector(element, selector)
|
||||
$.find.matchesSelector(element, selector)
|
||||
matchingScopedProperties.sort (a, b) ->
|
||||
if a.specificity == b.specificity
|
||||
b.index - a.index
|
||||
|
||||
@@ -4,7 +4,7 @@ Package = require './package'
|
||||
AtomPackage = require './atom-package'
|
||||
|
||||
_ = require 'underscore-plus'
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
fsUtils = require './fs-utils'
|
||||
|
||||
# Private: Handles discovering and loading available themes.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
ipc = require 'ipc'
|
||||
shell = require 'shell'
|
||||
@@ -21,7 +21,7 @@ class WindowEventHandler
|
||||
|
||||
@subscribe $(window), 'focus', -> $("body").removeClass('is-blurred')
|
||||
|
||||
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
|
||||
@subscribe $(window), 'blur', -> $("body").addClass('is-blurred')
|
||||
|
||||
@subscribe $(window), 'window:open-path', (event, {pathToOpen, initialLine}) ->
|
||||
unless fsUtils.isDirectorySync(pathToOpen)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
path = require 'path'
|
||||
$ = require './jquery-extensions'
|
||||
{$} = require './space-pen-extensions'
|
||||
_ = require 'underscore-plus'
|
||||
ipc = require 'ipc'
|
||||
WindowEventHandler = require './window-event-handler'
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<body tabindex="-1">
|
||||
</body>
|
||||
</html>
|
||||
|
||||
2
vendor/jasmine-jquery.js
vendored
2
vendor/jasmine-jquery.js
vendored
@@ -175,4 +175,4 @@ beforeEach(function() {
|
||||
afterEach(function() {
|
||||
jasmine.JQuery.events.cleanUp();
|
||||
});
|
||||
})(require('jquery'));
|
||||
})(require('../src/space-pen-extensions').jQuery);
|
||||
|
||||
9244
vendor/jquery.js
vendored
9244
vendor/jquery.js
vendored
File diff suppressed because it is too large
Load Diff
118
vendor/stringscore.js
vendored
118
vendor/stringscore.js
vendored
@@ -1,118 +0,0 @@
|
||||
// MODIFIED BY NS/CJ - Don't extend the prototype of String
|
||||
// MODIFIED BY CJ - Remove start_of_string_bonus
|
||||
|
||||
/*!
|
||||
* string_score.js: String Scoring Algorithm 0.1.10
|
||||
*
|
||||
* http://joshaven.com/string_score
|
||||
* https://github.com/joshaven/string_score
|
||||
*
|
||||
* Copyright (C) 2009-2011 Joshaven Potter <yourtech@gmail.com>
|
||||
* Special thanks to all of the contributors listed here https://github.com/joshaven/string_score
|
||||
* MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Date: Tue Mar 1 2011
|
||||
*/
|
||||
|
||||
/**
|
||||
* Scores a string against another string.
|
||||
* 'Hello World'.score('he'); //=> 0.5931818181818181
|
||||
* 'Hello World'.score('Hello'); //=> 0.7318181818181818
|
||||
*/
|
||||
module.exports = function(string, abbreviation, fuzziness) {
|
||||
// If the string is equal to the abbreviation, perfect match.
|
||||
if (string == abbreviation) {return 1;}
|
||||
// If it's not a perfect match and is empty return 0
|
||||
if (abbreviation == "") {return 0;}
|
||||
|
||||
var total_character_score = 0,
|
||||
abbreviation_length = abbreviation.length,
|
||||
string_length = string.length,
|
||||
start_of_string_bonus,
|
||||
abbreviation_score,
|
||||
fuzzies=1,
|
||||
final_score;
|
||||
|
||||
// Walk through abbreviation and add up scores.
|
||||
for (var i = 0,
|
||||
character_score/* = 0*/,
|
||||
index_in_string/* = 0*/,
|
||||
c/* = ''*/,
|
||||
index_c_lowercase/* = 0*/,
|
||||
index_c_uppercase/* = 0*/,
|
||||
min_index/* = 0*/;
|
||||
i < abbreviation_length;
|
||||
++i) {
|
||||
|
||||
// Find the first case-insensitive match of a character.
|
||||
c = abbreviation.charAt(i);
|
||||
|
||||
index_c_lowercase = string.indexOf(c.toLowerCase());
|
||||
index_c_uppercase = string.indexOf(c.toUpperCase());
|
||||
min_index = Math.min(index_c_lowercase, index_c_uppercase);
|
||||
index_in_string = (min_index > -1) ? min_index : Math.max(index_c_lowercase, index_c_uppercase);
|
||||
|
||||
if (index_in_string === -1) {
|
||||
if (fuzziness) {
|
||||
fuzzies += 1-fuzziness;
|
||||
continue;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
character_score = 0.1;
|
||||
}
|
||||
|
||||
// Set base score for matching 'c'.
|
||||
|
||||
// Same case bonus.
|
||||
if (string[index_in_string] === c) {
|
||||
character_score += 0.1;
|
||||
}
|
||||
|
||||
// Consecutive letter & start-of-string Bonus
|
||||
if (index_in_string === 0) {
|
||||
// Increase the score when matching first character of the remainder of the string
|
||||
character_score += 0.6;
|
||||
if (i === 0) {
|
||||
// If match is the first character of the string
|
||||
// & the first character of abbreviation, add a
|
||||
// start-of-string match bonus.
|
||||
// start_of_string_bonus = 1 //true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Acronym Bonus
|
||||
// Weighing Logic: Typing the first character of an acronym is as if you
|
||||
// preceded it with two perfect character matches.
|
||||
if (string.charAt(index_in_string - 1) === ' ') {
|
||||
character_score += 0.8; // * Math.min(index_in_string, 5); // Cap bonus at 0.4 * 5
|
||||
}
|
||||
}
|
||||
|
||||
// Left trim the already matched part of the string
|
||||
// (forces sequential matching).
|
||||
string = string.substring(index_in_string + 1, string_length);
|
||||
|
||||
total_character_score += character_score;
|
||||
} // end of for loop
|
||||
|
||||
// Uncomment to weigh smaller words higher.
|
||||
// return total_character_score / string_length;
|
||||
|
||||
abbreviation_score = total_character_score / abbreviation_length;
|
||||
//percentage_of_matched_string = abbreviation_length / string_length;
|
||||
//word_score = abbreviation_score * percentage_of_matched_string;
|
||||
|
||||
// Reduce penalty for longer strings.
|
||||
//final_score = (word_score + abbreviation_score) / 2;
|
||||
final_score = ((abbreviation_score * (abbreviation_length / string_length)) + abbreviation_score) / 2;
|
||||
|
||||
final_score = final_score / fuzzies;
|
||||
|
||||
if (start_of_string_bonus && (final_score + 0.15 < 1)) {
|
||||
final_score += 0.15;
|
||||
}
|
||||
|
||||
return final_score;
|
||||
};
|
||||
Reference in New Issue
Block a user