mirror of
https://github.com/atom/atom.git
synced 2026-02-16 01:25:13 -05:00
Merge branch 'master' into api/docs
This commit is contained in:
@@ -1057,11 +1057,11 @@ class Editor extends View
|
||||
|
||||
remove: (selector, keepData) ->
|
||||
return super if keepData or @removed
|
||||
@trigger 'editor:will-be-removed'
|
||||
super
|
||||
rootView?.focus()
|
||||
|
||||
beforeRemove: ->
|
||||
@trigger 'editor:will-be-removed'
|
||||
@removed = true
|
||||
@activeEditSession?.destroy()
|
||||
$(window).off(".editor-#{@id}")
|
||||
|
||||
@@ -166,7 +166,7 @@ class Pane extends View
|
||||
uri = item.getUri()
|
||||
atom.confirm(
|
||||
"'#{item.getTitle?() ? item.getUri()}' has changes, do you want to save them?"
|
||||
"Your changes will be lost if close this item without saving."
|
||||
"Your changes will be lost if you close this item without saving."
|
||||
"Save", => @saveItem(item, nextAction)
|
||||
"Cancel", cancelAction
|
||||
"Don't Save", nextAction
|
||||
|
||||
@@ -290,7 +290,7 @@ class Project
|
||||
readLine(line) if state is 'readingLines'
|
||||
|
||||
command = require.resolve('nak')
|
||||
args = ['--ackmate', regex.source, @getPath()]
|
||||
args = ['--hidden', '--ackmate', regex.source, @getPath()]
|
||||
args.unshift("--addVCSIgnores") if config.get('core.excludeVcsIgnoredPaths')
|
||||
new BufferedProcess({command, args, stdout, exit})
|
||||
deferred
|
||||
|
||||
@@ -32,9 +32,11 @@ class SelectList extends View
|
||||
@on 'core:move-to-top', =>
|
||||
@selectItem(@list.find('li:first'))
|
||||
@list.scrollToTop()
|
||||
false
|
||||
@on 'core:move-to-bottom', =>
|
||||
@selectItem(@list.find('li:last'))
|
||||
@list.scrollToBottom()
|
||||
false
|
||||
@on 'core:confirm', => @confirmSelection()
|
||||
@on 'core:cancel', => @cancel()
|
||||
|
||||
|
||||
@@ -164,13 +164,11 @@ window.reload = ->
|
||||
timesReloaded = process.global.timesReloaded ? 0
|
||||
++timesReloaded
|
||||
|
||||
restartValue = if window.location.search.indexOf('spec-bootstrap') == -1 then 10 else 3
|
||||
|
||||
if timesReloaded > restartValue
|
||||
if timesReloaded > 3
|
||||
atom.restartRendererProcess()
|
||||
else
|
||||
$native.reload()
|
||||
process.global.timesReloaded = timesReloaded
|
||||
$native.reload()
|
||||
|
||||
window.onerror = ->
|
||||
atom.showDevTools()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
Range = require 'range'
|
||||
SelectList = require 'select-list'
|
||||
@@ -22,7 +23,8 @@ class AutocompleteView extends SelectList
|
||||
|
||||
itemForElement: (match) ->
|
||||
$$ ->
|
||||
@li match.word
|
||||
@li =>
|
||||
@span match.word
|
||||
|
||||
handleEvents: ->
|
||||
@editor.on 'editor:path-changed', => @setCurrentBuffer(@editor.getBuffer())
|
||||
@@ -156,7 +158,15 @@ class AutocompleteView extends SelectList
|
||||
|
||||
{prefix, suffix}
|
||||
|
||||
afterAttach: (onDom) ->
|
||||
if onDom
|
||||
widestCompletion = parseInt(@css('min-width')) or 0
|
||||
@list.find('span').each ->
|
||||
widestCompletion = Math.max(widestCompletion, $(this).outerWidth())
|
||||
@list.width(widestCompletion)
|
||||
@width(@list.outerWidth())
|
||||
|
||||
populateList: ->
|
||||
super()
|
||||
super
|
||||
|
||||
@setPosition()
|
||||
|
||||
@@ -416,3 +416,12 @@ describe "AutocompleteView", ->
|
||||
|
||||
editor.trigger 'core:move-up'
|
||||
expect(editor.getCursorBufferPosition().row).toBe 0
|
||||
|
||||
it "sets the width of the view to be wide enough to contain the longest completion without scrolling", ->
|
||||
editor.attachToDom()
|
||||
editor.insertText('thisIsAReallyReallyReallyLongCompletion ')
|
||||
editor.moveCursorToBottom()
|
||||
editor.insertNewline
|
||||
editor.insertText('t')
|
||||
autocomplete.attach()
|
||||
expect(autocomplete.list.prop('scrollWidth')).toBe autocomplete.list.width()
|
||||
|
||||
@@ -8,3 +8,15 @@
|
||||
overflow-y: scroll;
|
||||
max-height: 200px;
|
||||
}
|
||||
|
||||
.select-list.autocomplete ol li {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
padding-left: 0px;
|
||||
padding-right: 0px;
|
||||
}
|
||||
|
||||
.autocomplete span {
|
||||
padding-left: 5px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ class LoadPathsTask
|
||||
args.unshift('--addVCSIgnores') if config.get('core.excludeVcsIgnoredPaths')
|
||||
args.unshift('--ignore', ignoredNames.join(',')) if ignoredNames.length > 0
|
||||
args.unshift('--follow')
|
||||
args.unshift('--hidden')
|
||||
|
||||
paths = []
|
||||
exit = (code) =>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
_ = require 'underscore'
|
||||
Subscriber = require 'subscriber'
|
||||
|
||||
module.exports =
|
||||
class GitDiffView
|
||||
@@ -9,58 +10,67 @@ class GitDiffView
|
||||
@gutter = @editor.gutter
|
||||
@diffs = {}
|
||||
|
||||
@editor.on 'editor:path-changed', => @subscribeToBuffer()
|
||||
@editor.on 'editor:display-updated', => @renderDiffs()
|
||||
git.on 'statuses-changed', =>
|
||||
@subscribe @editor, 'editor:path-changed', @subscribeToBuffer
|
||||
@subscribe @editor, 'editor:display-updated', @renderDiffs
|
||||
@subscribe git, 'statuses-changed', =>
|
||||
@diffs = {}
|
||||
@scheduleDiffs()
|
||||
git.on 'status-changed', (path) =>
|
||||
@scheduleUpdate()
|
||||
@subscribe git, 'status-changed', (path) =>
|
||||
delete @diffs[path]
|
||||
@scheduleDiffs() if path is @editor.getPath()
|
||||
@scheduleUpdate() if path is @editor.getPath()
|
||||
|
||||
@subscribeToBuffer()
|
||||
|
||||
subscribeToBuffer: ->
|
||||
beforeRemove: ->
|
||||
@unsubscribe()
|
||||
@unsubscribeFromBuffer()
|
||||
|
||||
unsubscribeFromBuffer: ->
|
||||
if @buffer?
|
||||
@removeDiffs()
|
||||
delete @diffs[@buffer.getPath()] if @buffer.destroyed
|
||||
@buffer.off '.git-diff'
|
||||
@buffer.off 'contents-modified', @updateDiffs
|
||||
@buffer = null
|
||||
|
||||
if @buffer = @editor.getBuffer()
|
||||
@scheduleDiffs() unless @diffs[@buffer.getPath()]?
|
||||
@buffer.on 'contents-modified.git-diff', =>
|
||||
@generateDiffs()
|
||||
@renderDiffs()
|
||||
subscribeToBuffer: =>
|
||||
@unsubscribeFromBuffer()
|
||||
|
||||
scheduleDiffs: ->
|
||||
_.nextTick =>
|
||||
@generateDiffs()
|
||||
@renderDiffs()
|
||||
if @buffer = @editor.getBuffer()
|
||||
@scheduleUpdate() unless @diffs[@buffer.getPath()]?
|
||||
@buffer.on 'contents-modified', @updateDiffs
|
||||
|
||||
scheduleUpdate: ->
|
||||
_.nextTick(@updateDiffs)
|
||||
|
||||
updateDiffs: =>
|
||||
@generateDiffs()
|
||||
@renderDiffs()
|
||||
|
||||
generateDiffs: ->
|
||||
if path = @buffer.getPath()
|
||||
@diffs[path] = git?.getLineDiffs(path, @buffer.getText())
|
||||
|
||||
removeDiffs: ->
|
||||
removeDiffs: =>
|
||||
if @gutter.hasGitLineDiffs
|
||||
@gutter.find('.line-number').removeClass('git-line-added git-line-modified git-line-removed')
|
||||
@gutter.hasGitLineDiffs = false
|
||||
|
||||
renderDiffs: ->
|
||||
renderDiffs: =>
|
||||
return unless @gutter.isVisible()
|
||||
|
||||
@removeDiffs()
|
||||
|
||||
hunks = @diffs[@editor.getPath()] ? []
|
||||
linesHighlighted = 0
|
||||
for hunk in hunks
|
||||
if hunk.oldLines is 0 and hunk.newLines > 0
|
||||
for row in [hunk.newStart...hunk.newStart + hunk.newLines]
|
||||
for {oldStart, newStart, oldLines, newLines} in hunks
|
||||
if oldLines is 0 and newLines > 0
|
||||
for row in [newStart...newStart + newLines]
|
||||
linesHighlighted += @gutter.find(".line-number[lineNumber=#{row - 1}]").addClass('git-line-added').length
|
||||
else if hunk.newLines is 0 and hunk.oldLines > 0
|
||||
linesHighlighted += @gutter.find(".line-number[lineNumber=#{hunk.newStart - 1}]").addClass('git-line-removed').length
|
||||
else if newLines is 0 and oldLines > 0
|
||||
linesHighlighted += @gutter.find(".line-number[lineNumber=#{newStart - 1}]").addClass('git-line-removed').length
|
||||
else
|
||||
for row in [hunk.newStart...hunk.newStart + hunk.newLines]
|
||||
for row in [newStart...newStart + newLines]
|
||||
linesHighlighted += @gutter.find(".line-number[lineNumber=#{row - 1}]").addClass('git-line-modified').length
|
||||
@gutter.hasGitLineDiffs = linesHighlighted > 0
|
||||
|
||||
_.extend GitDiffView.prototype, Subscriber
|
||||
|
||||
@@ -11,27 +11,30 @@ class SpellCheckView extends View
|
||||
views: []
|
||||
|
||||
initialize: (@editor) ->
|
||||
@subscribe @editor, 'editor:path-changed', => @subscribeToBuffer()
|
||||
@subscribe @editor, 'editor:grammar-changed', => @subscribeToBuffer()
|
||||
@observeConfig 'editor.fontSize', => @subscribeToBuffer()
|
||||
@observeConfig 'spell-check.grammars', => @subscribeToBuffer()
|
||||
@subscribe @editor, 'editor:path-changed', @subscribeToBuffer
|
||||
@subscribe @editor, 'editor:grammar-changed', @subscribeToBuffer
|
||||
@observeConfig 'editor.fontSize', @subscribeToBuffer
|
||||
@observeConfig 'spell-check.grammars', @subscribeToBuffer
|
||||
|
||||
@subscribeToBuffer()
|
||||
|
||||
beforeRemove: ->
|
||||
@unsubscribeFromBuffer()
|
||||
|
||||
unsubscribeFromBuffer: ->
|
||||
@destroyViews()
|
||||
@task?.abort()
|
||||
|
||||
if @buffer?
|
||||
@buffer.off '.spell-check'
|
||||
@buffer.off 'contents-modified', @updateMisspellings
|
||||
@buffer = null
|
||||
|
||||
subscribeToBuffer: ->
|
||||
subscribeToBuffer: =>
|
||||
@unsubscribeFromBuffer()
|
||||
|
||||
if @spellCheckCurrentGrammar()
|
||||
@buffer = @editor.getBuffer()
|
||||
@buffer.on 'contents-modified.spell-check', => @updateMisspellings()
|
||||
@buffer.on 'contents-modified', @updateMisspellings
|
||||
@updateMisspellings()
|
||||
|
||||
spellCheckCurrentGrammar: ->
|
||||
@@ -49,11 +52,7 @@ class SpellCheckView extends View
|
||||
@views.push(view)
|
||||
@append(view)
|
||||
|
||||
updateMisspellings: ->
|
||||
unless @editor.activeEditSession?
|
||||
@unsubscribeFromBuffer()
|
||||
return
|
||||
|
||||
updateMisspellings: =>
|
||||
@task?.abort()
|
||||
|
||||
callback = (misspellings) =>
|
||||
|
||||
@@ -35,23 +35,31 @@ class StatusBarView extends View
|
||||
if git?
|
||||
@subscribe git, 'status-changed', (path, status) =>
|
||||
@updateStatusBar() if path is @getActiveItemPath()
|
||||
@subscribe git, 'statuses-changed', =>
|
||||
@updateStatusBar()
|
||||
@subscribe git, 'statuses-changed', @updateStatusBar
|
||||
|
||||
@subscribeToBuffer()
|
||||
|
||||
beforeRemove: ->
|
||||
@unsubscribeFromBuffer()
|
||||
|
||||
getActiveItemPath: ->
|
||||
@pane.activeItem?.getPath?()
|
||||
|
||||
unsubscribeFromBuffer: ->
|
||||
if @buffer?
|
||||
@buffer.off 'modified-status-changed', @updateBufferHasModifiedText
|
||||
@buffer.off 'saved', @updateStatusBar
|
||||
@buffer = null
|
||||
|
||||
subscribeToBuffer: ->
|
||||
@buffer?.off '.status-bar'
|
||||
@unsubscribeFromBuffer()
|
||||
if @buffer = @pane.activeItem.getBuffer?()
|
||||
@buffer.on 'modified-status-changed.status-bar', (isModified) => @updateBufferHasModifiedText(isModified)
|
||||
@buffer.on 'saved.status-bar', => @updateStatusBar()
|
||||
@buffer.on 'modified-status-changed', @updateBufferHasModifiedText
|
||||
@buffer.on 'saved', @updateStatusBar
|
||||
|
||||
@updateStatusBar()
|
||||
|
||||
updateStatusBar: ->
|
||||
updateStatusBar: =>
|
||||
@updateGrammarText()
|
||||
@updateBranchText()
|
||||
@updateBufferHasModifiedText(@buffer?.isModified())
|
||||
@@ -65,7 +73,7 @@ class StatusBarView extends View
|
||||
else
|
||||
@grammarName.text(grammar.name).show()
|
||||
|
||||
updateBufferHasModifiedText: (isModified)->
|
||||
updateBufferHasModifiedText: (isModified) =>
|
||||
if isModified
|
||||
@bufferModified.text('*') unless @isModified
|
||||
@isModified = true
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
ctags = require 'ctags'
|
||||
fsUtils = require 'fs-utils'
|
||||
path = require 'path'
|
||||
|
||||
module.exports =
|
||||
getTagsFile: (path) ->
|
||||
tagsFile = fsUtils.join(path, "tags")
|
||||
getTagsFile: (tagsFilePath) ->
|
||||
tagsFile = path.join(tagsFilePath, "tags")
|
||||
return tagsFile if fsUtils.isFile(tagsFile)
|
||||
|
||||
tagsFile = fsUtils.join(path, "TAGS")
|
||||
tagsFile = path.join(tagsFilePath, "TAGS")
|
||||
return tagsFile if fsUtils.isFile(tagsFile)
|
||||
|
||||
loadTags: (path) ->
|
||||
tagsFile = @getTagsFile(path)
|
||||
loadTags: (tagsFilePath) ->
|
||||
tagsFile = @getTagsFile(tagsFilePath)
|
||||
if tagsFile
|
||||
callTaskMethod("tagsLoaded", ctags.getTags(tagsFile))
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user