mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 23:48:05 +03:00
Merge branch 'master' of github.com:github/atom into toggle-comments
This commit is contained in:
commit
a033d13c1a
12
Rakefile
12
Rakefile
@ -56,15 +56,17 @@ task :"copy-files-to-bundle" => :"verify-prerequisites" do
|
||||
|
||||
dest = File.join(built_dir, contents_dir, "Resources")
|
||||
|
||||
%w(index.html src static vendor spec benchmark).each do |dir|
|
||||
rm_rf File.join(dest, "index.html")
|
||||
cp "index.html", File.join(dest, "index.html")
|
||||
|
||||
sh "coffee -c -o #{dest}/src/stdlib src/stdlib/require.coffee"
|
||||
unless ENV['LOAD_RESOURCES_FROM_DIR']
|
||||
%w(src static vendor spec benchmark).each do |dir|
|
||||
rm_rf File.join(dest, dir)
|
||||
cp_r dir, File.join(dest, dir)
|
||||
end
|
||||
|
||||
if ENV['LOAD_RESOURCES_FROM_DIR']
|
||||
sh "coffee -c #{dest}/src/stdlib/require.coffee"
|
||||
else
|
||||
sh "coffee -c #{dest}/src #{dest}/vendor #{dest}/spec"
|
||||
sh "coffee -c #{dest}/src #{dest}/vendor #{dest}/spec #{dest}/benchmark"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -2457,6 +2457,19 @@ describe "Editor", ->
|
||||
editor.trigger "toggle-fold"
|
||||
expect(editor.screenLineForRow(1).fold).toBeUndefined()
|
||||
|
||||
it "creates/destroys the largest fold containing the cursor position", ->
|
||||
editor.trigger "fold-all"
|
||||
editor.setCursorBufferPosition([5,1])
|
||||
|
||||
editor.trigger "toggle-fold"
|
||||
expect(editor.screenLineForRow(0).fold).toBeUndefined()
|
||||
expect(editor.screenLineForRow(1).fold).toBeDefined()
|
||||
|
||||
editor.trigger "toggle-fold"
|
||||
expect(editor.screenLineForRow(0).fold).toBeUndefined()
|
||||
expect(editor.screenLineForRow(1).fold).toBeUndefined()
|
||||
expect(editor.screenLineForRow(4).fold).toBeDefined()
|
||||
|
||||
describe "when a fold-all event is triggered", ->
|
||||
it "creates folds on every line that can be folded", ->
|
||||
editor.setCursorBufferPosition([5,13])
|
||||
@ -2465,6 +2478,11 @@ describe "Editor", ->
|
||||
expect(editor.screenLineForRow(0).fold).toBeDefined()
|
||||
expect(editor.screenLineForRow(1)).toBeUndefined()
|
||||
|
||||
it "maintains cursor buffer position when buffer is created/destroyed", ->
|
||||
editor.setCursorBufferPosition([5,5])
|
||||
editor.trigger "fold-all"
|
||||
expect(editor.getCursorBufferPosition()).toEqual([5,5])
|
||||
|
||||
describe "primitive folding", ->
|
||||
beforeEach ->
|
||||
editor.setBuffer(new Buffer(require.resolve('fixtures/two-hundred.txt')))
|
||||
|
@ -27,7 +27,7 @@ describe "FoldSuggester", ->
|
||||
|
||||
describe "coffeescript", ->
|
||||
beforeEach ->
|
||||
buffer = new Buffer(require.resolve 'fixtures/sample.coffee')
|
||||
buffer = new Buffer(require.resolve 'fixtures/coffee.coffee')
|
||||
highlighter = new Highlighter(buffer)
|
||||
foldSuggester = new FoldSuggester(highlighter)
|
||||
|
||||
|
@ -307,6 +307,33 @@ describe "Renderer", ->
|
||||
expect(line4.screenDelta).toEqual [1, 0]
|
||||
expect(line5.text).toMatch /9-+/
|
||||
|
||||
describe "when creating a fold where one already exists", ->
|
||||
it "returns existing fold and does't create new fold", ->
|
||||
fold = renderer.createFold(0,10)
|
||||
expect(renderer.activeFolds[0].length).toBe 1
|
||||
|
||||
newFold = renderer.createFold(0,10)
|
||||
expect(newFold).toBe fold
|
||||
expect(renderer.activeFolds[0].length).toBe 1
|
||||
|
||||
describe "when a fold is created inside an existing folded region", ->
|
||||
it "creates/destroys the fold, but does not trigger change event", ->
|
||||
outerFold = renderer.createFold(0, 10)
|
||||
changeHandler.reset()
|
||||
|
||||
innerFold = renderer.createFold(2, 5)
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
[line0, line1] = renderer.linesForRows(0, 1)
|
||||
expect(line0.fold).toBe outerFold
|
||||
expect(line1.fold).toBeUndefined()
|
||||
|
||||
changeHandler.reset()
|
||||
innerFold.destroy()
|
||||
expect(changeHandler).not.toHaveBeenCalled()
|
||||
[line0, line1] = renderer.linesForRows(0, 1)
|
||||
expect(line0.fold).toBe outerFold
|
||||
expect(line1.fold).toBeUndefined()
|
||||
|
||||
describe "when the buffer changes", ->
|
||||
[fold1, fold2] = []
|
||||
beforeEach ->
|
||||
@ -575,6 +602,3 @@ describe "Renderer", ->
|
||||
|
||||
describe ".bufferRowsForScreenRows()", ->
|
||||
it "returns the buffer rows corresponding to each screen row in the given range", ->
|
||||
renderer.setMaxLineLength(50)
|
||||
renderer.createFold(4, 7)
|
||||
expect(renderer.bufferRowsForScreenRows()).toEqual [0, 1, 2, 3, 3, 4, 8, 8, 9, 10, 11, 12]
|
||||
|
@ -34,9 +34,10 @@ describe 'FileFinder', ->
|
||||
expect(finder.miniEditor.getText()).toBe ''
|
||||
|
||||
it "shows all relative file paths for the current project and selects the first", ->
|
||||
finder.maxResults = 1000
|
||||
rootView.trigger 'file-finder:toggle'
|
||||
rootView.project.getFilePaths().done (paths) ->
|
||||
expect(finder.pathList.children('li').length).toBe paths.length
|
||||
expect(finder.pathList.children('li').length).toBe paths.length, finder.maxResults
|
||||
for path in paths
|
||||
expect(finder.pathList.find("li:contains(#{path})")).toExist()
|
||||
expect(finder.pathList.children().first()).toHaveClass 'selected'
|
||||
@ -161,17 +162,14 @@ describe 'FileFinder', ->
|
||||
finder.trigger 'file-finder:select-file'
|
||||
expect(finder.hasParent()).toBeTruthy()
|
||||
|
||||
describe "findMatches(queryString)", ->
|
||||
describe ".findMatches(queryString)", ->
|
||||
beforeEach ->
|
||||
rootView.trigger 'file-finder:toggle'
|
||||
|
||||
it "returns up to finder.maxResults paths if queryString is empty", ->
|
||||
expect(finder.paths.length).toBeLessThan finder.maxResults
|
||||
expect(finder.findMatches('').length).toBe finder.paths.length
|
||||
|
||||
finder.maxResults = finder.paths.length - 1
|
||||
|
||||
expect(finder.findMatches('').length).toBe finder.maxResults
|
||||
expect(finder.findMatches('').length).toBeLessThan finder.maxResults + 1
|
||||
finder.maxResults = 5
|
||||
expect(finder.findMatches('').length).toBeLessThan finder.maxResults + 1
|
||||
|
||||
it "returns paths sorted by score of match against the given query", ->
|
||||
finder.paths = ["app.coffee", "atom/app.coffee"]
|
||||
|
@ -7,6 +7,8 @@ Directory = require 'directory'
|
||||
require 'window'
|
||||
window.showConsole()
|
||||
|
||||
requireStylesheet "jasmine.css"
|
||||
|
||||
defaultTitle = document.title
|
||||
directoriesWithSubscriptions = null
|
||||
|
||||
|
@ -810,7 +810,8 @@ class Editor extends View
|
||||
@renderer.foldAll()
|
||||
|
||||
toggleFold: ->
|
||||
@renderer.toggleFoldAtBufferRow(@getCursorBufferPosition().row)
|
||||
row = @renderer.bufferPositionForScreenPosition(@getCursorScreenPosition()).row
|
||||
@renderer.toggleFoldAtBufferRow(row)
|
||||
|
||||
foldSelection: -> @getSelection().fold()
|
||||
|
||||
|
@ -41,6 +41,9 @@ class Fold
|
||||
isContainedByRange: (range) ->
|
||||
range.start.row <= @startRow and @endRow <= range.end.row
|
||||
|
||||
isContainedByFold: (fold) ->
|
||||
@isContainedByRange(fold.getBufferRange())
|
||||
|
||||
updateStartRow: (event) ->
|
||||
{ newRange, oldRange } = event
|
||||
|
||||
|
@ -19,4 +19,4 @@ class Gutter extends View
|
||||
@div {class: 'line-number'}, if row == lastScreenRow then '•' else row + 1
|
||||
lastScreenRow = row
|
||||
|
||||
@lineNumbers.width(editor.getLastScreenRow().toString().length * editor.charWidth)
|
||||
@lineNumbers.width(editor.buffer.getLastRow().toString().length * editor.charWidth)
|
||||
|
@ -55,7 +55,7 @@ class Renderer
|
||||
@lineMap.bufferRowsForScreenRows(startRow, endRow)
|
||||
|
||||
foldAll: ->
|
||||
for currentRow in [@buffer.getLastRow()..0]
|
||||
for currentRow in [0..@buffer.getLastRow()]
|
||||
[startRow, endRow] = @foldSuggester.rowRangeForFoldAtBufferRow(currentRow) ? []
|
||||
continue unless startRow?
|
||||
|
||||
@ -73,6 +73,11 @@ class Renderer
|
||||
|
||||
break
|
||||
|
||||
isFoldContainedByActiveFold: (fold) ->
|
||||
for row, folds of @activeFolds
|
||||
for otherFold in folds
|
||||
return otherFold if fold != otherFold and fold.isContainedByFold(otherFold)
|
||||
|
||||
foldFor: (startRow, endRow) ->
|
||||
_.find @activeFolds[startRow] ? [], (fold) ->
|
||||
fold.startRow == startRow and fold.endRow == endRow
|
||||
@ -82,6 +87,7 @@ class Renderer
|
||||
fold = new Fold(this, startRow, endRow)
|
||||
@registerFold(fold)
|
||||
|
||||
unless @isFoldContainedByActiveFold(fold)
|
||||
bufferRange = new Range([startRow, 0], [endRow, @buffer.lineLengthForRow(endRow)])
|
||||
oldScreenRange = @screenLineRangeForBufferRange(bufferRange)
|
||||
|
||||
@ -90,12 +96,13 @@ class Renderer
|
||||
newScreenRange = @screenLineRangeForBufferRange(bufferRange)
|
||||
|
||||
@trigger 'change', oldRange: oldScreenRange, newRange: newScreenRange, lineNumbersChanged: true
|
||||
@trigger 'fold', bufferRange
|
||||
|
||||
fold
|
||||
|
||||
destroyFold: (fold) ->
|
||||
@unregisterFold(fold.startRow, fold)
|
||||
|
||||
unless @isFoldContainedByActiveFold(fold)
|
||||
{ startRow, endRow } = fold
|
||||
bufferRange = new Range([startRow, 0], [endRow, @buffer.lineLengthForRow(endRow)])
|
||||
oldScreenRange = @screenLineRangeForBufferRange(bufferRange)
|
||||
@ -104,7 +111,6 @@ class Renderer
|
||||
newScreenRange = @screenLineRangeForBufferRange(bufferRange)
|
||||
|
||||
@trigger 'change', oldRange: oldScreenRange, newRange: newScreenRange, lineNumbersChanged: true
|
||||
@trigger 'unfold', bufferRange
|
||||
|
||||
destroyFoldsContainingBufferRow: (bufferRow) ->
|
||||
folds = @activeFolds[bufferRow] ? []
|
||||
|
3
vendor/jasmine-helper.coffee
vendored
3
vendor/jasmine-helper.coffee
vendored
@ -7,9 +7,6 @@ module.exports.runSpecSuite = (specSuite, logErrors=true) ->
|
||||
|
||||
$ = require 'jquery'
|
||||
|
||||
$('head').append $$ ->
|
||||
@link rel: "stylesheet", type: "text/css", href: "static/jasmine.css"
|
||||
|
||||
$('body').append $$ ->
|
||||
@div id: 'jasmine-content'
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user