mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge remote-tracking branch 'refs/remotes/origin/master' into wl-electron-35
This commit is contained in:
@@ -136,12 +136,9 @@ class ContextMenuManager
|
||||
|
||||
for itemSet in matchingItemSets
|
||||
for item in itemSet.items
|
||||
continue if item.devMode and not @devMode
|
||||
item = Object.create(item)
|
||||
if typeof item.shouldDisplay is 'function'
|
||||
continue unless item.shouldDisplay(event)
|
||||
item.created?(event)
|
||||
MenuHelpers.merge(currentTargetItems, item, itemSet.specificity)
|
||||
itemForEvent = @cloneItemForEvent(item, event)
|
||||
if itemForEvent
|
||||
MenuHelpers.merge(currentTargetItems, itemForEvent, itemSet.specificity)
|
||||
|
||||
for item in currentTargetItems
|
||||
MenuHelpers.merge(template, item, false)
|
||||
@@ -150,6 +147,19 @@ class ContextMenuManager
|
||||
|
||||
template
|
||||
|
||||
# Returns an object compatible with `::add()` or `null`.
|
||||
cloneItemForEvent: (item, event) ->
|
||||
return null if item.devMode and not @devMode
|
||||
item = Object.create(item)
|
||||
if typeof item.shouldDisplay is 'function'
|
||||
return null unless item.shouldDisplay(event)
|
||||
item.created?(event)
|
||||
if Array.isArray(item.submenu)
|
||||
item.submenu = item.submenu
|
||||
.map((submenuItem) => @cloneItemForEvent(submenuItem, event))
|
||||
.filter((submenuItem) -> submenuItem isnt null)
|
||||
return item
|
||||
|
||||
convertLegacyItemsBySelector: (legacyItemsBySelector, devMode) ->
|
||||
itemsBySelector = {}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class DefaultDirectoryProvider
|
||||
# * `uri` {String} The path to the directory to add. This is guaranteed not to
|
||||
# be contained by a {Directory} in `atom.project`.
|
||||
#
|
||||
# Returns a Promise that resolves to:
|
||||
# Returns a {Promise} that resolves to:
|
||||
# * {Directory} if the given URI is compatible with this provider.
|
||||
# * `null` if the given URI is not compatibile with this provider.
|
||||
directoryForURI: (uri) ->
|
||||
|
||||
@@ -12,12 +12,16 @@ class FileSystemBlobStore {
|
||||
}
|
||||
|
||||
constructor (directory) {
|
||||
this.inMemoryBlobs = new Map()
|
||||
this.invalidationKeys = {}
|
||||
this.blobFilename = path.join(directory, 'BLOB')
|
||||
this.blobMapFilename = path.join(directory, 'MAP')
|
||||
this.invalidationKeysFilename = path.join(directory, 'INVKEYS')
|
||||
this.lockFilename = path.join(directory, 'LOCK')
|
||||
this.reset()
|
||||
}
|
||||
|
||||
reset () {
|
||||
this.inMemoryBlobs = new Map()
|
||||
this.invalidationKeys = {}
|
||||
this.storedBlob = new Buffer(0)
|
||||
this.storedBlobMap = {}
|
||||
}
|
||||
@@ -32,9 +36,14 @@ class FileSystemBlobStore {
|
||||
if (!fs.existsSync(this.invalidationKeysFilename)) {
|
||||
return
|
||||
}
|
||||
this.storedBlob = fs.readFileSync(this.blobFilename)
|
||||
this.storedBlobMap = JSON.parse(fs.readFileSync(this.blobMapFilename))
|
||||
this.invalidationKeys = JSON.parse(fs.readFileSync(this.invalidationKeysFilename))
|
||||
|
||||
try {
|
||||
this.storedBlob = fs.readFileSync(this.blobFilename)
|
||||
this.storedBlobMap = JSON.parse(fs.readFileSync(this.blobMapFilename))
|
||||
this.invalidationKeys = JSON.parse(fs.readFileSync(this.invalidationKeysFilename))
|
||||
} catch (e) {
|
||||
this.reset()
|
||||
}
|
||||
}
|
||||
|
||||
save () {
|
||||
|
||||
@@ -32,11 +32,16 @@ export default class GitRepositoryAsync {
|
||||
}
|
||||
|
||||
constructor (_path, options = {}) {
|
||||
Git.enableThreadSafety()
|
||||
|
||||
this.emitter = new Emitter()
|
||||
this.subscriptions = new CompositeDisposable()
|
||||
this.pathStatusCache = {}
|
||||
// NB: This needs to happen before the following .openRepository call.
|
||||
|
||||
// NB: These needs to happen before the following .openRepository call.
|
||||
this.openedPath = _path
|
||||
this._openExactPath = options.openExactPath || false
|
||||
|
||||
this.repoPromise = this.openRepository()
|
||||
this.isCaseInsensitive = fs.isCaseInsensitive()
|
||||
this.upstream = {}
|
||||
@@ -846,22 +851,30 @@ export default class GitRepositoryAsync {
|
||||
|
||||
const submodule = await Git.Submodule.lookup(repo, name)
|
||||
const absolutePath = path.join(repo.workdir(), submodule.path())
|
||||
const submoduleRepo = GitRepositoryAsync.open(absolutePath)
|
||||
const submoduleRepo = GitRepositoryAsync.open(absolutePath, {openExactPath: true, refreshOnWindowFocus: false})
|
||||
this.submodules[name] = submoduleRepo
|
||||
}
|
||||
|
||||
for (const name in this.submodules) {
|
||||
if (submoduleNames.indexOf(name) < 0) {
|
||||
const repo = this.submodules[name]
|
||||
const repo = this.submodules[name]
|
||||
const gone = submoduleNames.indexOf(name) < 0
|
||||
if (gone) {
|
||||
repo.destroy()
|
||||
delete this.submodules[name]
|
||||
} else {
|
||||
try {
|
||||
await repo.refreshStatus()
|
||||
} catch (e) {
|
||||
// libgit2 will sometimes report submodules that aren't actually valid
|
||||
// (https://github.com/libgit2/libgit2/issues/3580). So check the
|
||||
// validity of the submodules by removing any that fail.
|
||||
repo.destroy()
|
||||
delete this.submodules[name]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const submoduleRepos = _.values(this.submodules)
|
||||
await Promise.all(submoduleRepos.map(s => s.refreshStatus()))
|
||||
|
||||
return submoduleRepos
|
||||
return _.values(this.submodules)
|
||||
}
|
||||
|
||||
// Get the status for the submodules in the repository.
|
||||
@@ -967,7 +980,11 @@ export default class GitRepositoryAsync {
|
||||
//
|
||||
// Returns the new {NodeGit.Repository}.
|
||||
openRepository () {
|
||||
return Git.Repository.openExt(this.openedPath, 0, '')
|
||||
if (this._openExactPath) {
|
||||
return Git.Repository.open(this.openedPath)
|
||||
} else {
|
||||
return Git.Repository.openExt(this.openedPath, 0, '')
|
||||
}
|
||||
}
|
||||
|
||||
// Section: Private
|
||||
|
||||
@@ -329,7 +329,7 @@ class Project extends Model
|
||||
#
|
||||
# * `filePath` A {String} representing a path. If `null`, an "Untitled" buffer is created.
|
||||
#
|
||||
# Returns a promise that resolves to the {TextBuffer}.
|
||||
# Returns a {Promise} that resolves to the {TextBuffer}.
|
||||
bufferForPath: (absoluteFilePath) ->
|
||||
existingBuffer = @findBufferForPath(absoluteFilePath) if absoluteFilePath?
|
||||
if existingBuffer
|
||||
@@ -349,7 +349,7 @@ class Project extends Model
|
||||
# * `absoluteFilePath` A {String} representing a path.
|
||||
# * `text` The {String} text to use as a buffer.
|
||||
#
|
||||
# Returns a promise that resolves to the {TextBuffer}.
|
||||
# Returns a {Promise} that resolves to the {TextBuffer}.
|
||||
buildBuffer: (absoluteFilePath) ->
|
||||
buffer = new TextBuffer({filePath: absoluteFilePath})
|
||||
@addBuffer(buffer)
|
||||
|
||||
@@ -403,7 +403,7 @@ class Workspace extends Model
|
||||
# If `false`, only the active pane will be searched for
|
||||
# an existing item for the same URI. Defaults to `false`.
|
||||
#
|
||||
# Returns a promise that resolves to the {TextEditor} for the file URI.
|
||||
# Returns a {Promise} that resolves to the {TextEditor} for the file URI.
|
||||
open: (uri, options={}) ->
|
||||
searchAllPanes = options.searchAllPanes
|
||||
split = options.split
|
||||
@@ -546,7 +546,7 @@ class Workspace extends Model
|
||||
# Public: Asynchronously reopens the last-closed item's URI if it hasn't already been
|
||||
# reopened.
|
||||
#
|
||||
# Returns a promise that is resolved when the item is opened
|
||||
# Returns a {Promise} that is resolved when the item is opened
|
||||
reopenItem: ->
|
||||
if uri = @destroyedItemURIs.pop()
|
||||
@open(uri)
|
||||
@@ -883,7 +883,7 @@ class Workspace extends Model
|
||||
# with number of paths searched.
|
||||
# * `iterator` {Function} callback on each file found.
|
||||
#
|
||||
# Returns a `Promise` with a `cancel()` method that will cancel all
|
||||
# Returns a {Promise} with a `cancel()` method that will cancel all
|
||||
# of the underlying searches that were started as part of this scan.
|
||||
scan: (regex, options={}, iterator) ->
|
||||
if _.isFunction(options)
|
||||
@@ -986,7 +986,7 @@ class Workspace extends Model
|
||||
# * `iterator` A {Function} callback on each file with replacements:
|
||||
# * `options` {Object} with keys `filePath` and `replacements`.
|
||||
#
|
||||
# Returns a `Promise`.
|
||||
# Returns a {Promise}.
|
||||
replace: (regex, replacementText, filePaths, iterator) ->
|
||||
new Promise (resolve, reject) =>
|
||||
openPaths = (buffer.getPath() for buffer in @project.getBuffers())
|
||||
|
||||
Reference in New Issue
Block a user