mirror of
https://github.com/atom/atom.git
synced 2026-04-06 03:02:13 -04:00
Merge remote-tracking branch 'origin/master' into config
Conflicts: src/app/keymap.coffee src/extensions/outline-view/src/keymap.coffee src/extensions/outline-view/src/tag-reader.coffee src/packages/fuzzy-finder/spec/fuzzy-finder-spec.coffee src/packages/fuzzy-finder/src/fuzzy-finder.coffee
This commit is contained in:
@@ -73,8 +73,10 @@ class Buffer
|
||||
@trigger "path-change", this
|
||||
|
||||
reload: ->
|
||||
@trigger 'before-reload'
|
||||
@updateCachedDiskContents()
|
||||
@setText(@cachedDiskContents)
|
||||
@trigger 'after-reload'
|
||||
|
||||
updateCachedDiskContents: ->
|
||||
@cachedDiskContents = @file.read()
|
||||
@@ -187,6 +189,9 @@ class Buffer
|
||||
|
||||
@change(new Range(startPoint, endPoint), '')
|
||||
|
||||
append: (text) ->
|
||||
@insert(@getEofPosition(), text)
|
||||
|
||||
insert: (point, text) ->
|
||||
@change(new Range(point, point), text)
|
||||
|
||||
|
||||
@@ -59,6 +59,8 @@ class EditSession
|
||||
@buffer.on "update-anchors-after-change.edit-session-#{@id}", =>
|
||||
@mergeCursors()
|
||||
|
||||
@preserveCursorPositionOnBufferReload()
|
||||
|
||||
@displayBuffer.on "change.edit-session-#{@id}", (e) =>
|
||||
@refreshAnchorScreenPositions() unless e.bufferDelta
|
||||
@trigger 'screen-lines-change', e
|
||||
@@ -597,4 +599,12 @@ class EditSession
|
||||
inspect: ->
|
||||
JSON.stringify @serialize()
|
||||
|
||||
preserveCursorPositionOnBufferReload: ->
|
||||
cursorPosition = null
|
||||
@buffer.on "before-reload.edit-session-#{@id}", =>
|
||||
cursorPosition = @getCursorBufferPosition()
|
||||
@buffer.on "after-reload.edit-session-#{@id}", =>
|
||||
@setCursorBufferPosition(cursorPosition) if cursorPosition
|
||||
cursorPosition = null
|
||||
|
||||
_.extend(EditSession.prototype, EventEmitter)
|
||||
|
||||
@@ -468,7 +468,7 @@ class Editor extends View
|
||||
@resetDisplay()
|
||||
|
||||
if @attached and @activeEditSession.buffer.isInConflict()
|
||||
@showBufferConflictAlert(@activeEditSession)
|
||||
setTimeout(( =>@showBufferConflictAlert(@activeEditSession)), 0) # Display after editSession has a chance to display
|
||||
|
||||
showBufferConflictAlert: (editSession) ->
|
||||
atom.confirm(
|
||||
|
||||
@@ -67,21 +67,42 @@ class LanguageMode
|
||||
|
||||
toggleLineCommentsForBufferRows: (start, end) ->
|
||||
scopes = @editSession.scopesForBufferPosition([start, 0])
|
||||
return unless commentString = TextMateBundle.lineCommentStringForScope(scopes[0])
|
||||
return unless commentStartString = TextMateBundle.lineCommentStartStringForScope(scopes[0])
|
||||
|
||||
commentRegexString = _.escapeRegExp(commentString)
|
||||
commentRegexString = commentRegexString.replace(/(\s+)$/, '($1)?')
|
||||
commentRegex = new OnigRegExp("^\s*#{commentRegexString}")
|
||||
buffer = @editSession.buffer
|
||||
commentStartRegexString = _.escapeRegExp(commentStartString).replace(/(\s+)$/, '($1)?')
|
||||
commentStartRegex = new OnigRegExp("^(\\s*)(#{commentStartRegexString})")
|
||||
shouldUncomment = commentStartRegex.test(buffer.lineForRow(start))
|
||||
|
||||
shouldUncomment = commentRegex.test(@editSession.lineForBufferRow(start))
|
||||
|
||||
for row in [start..end]
|
||||
line = @editSession.lineForBufferRow(row)
|
||||
if commentEndString = TextMateBundle.lineCommentEndStringForScope(scopes[0])
|
||||
if shouldUncomment
|
||||
if match = commentRegex.search(line)
|
||||
@editSession.buffer.change([[row, 0], [row, match[0].length]], "")
|
||||
commentEndRegexString = _.escapeRegExp(commentEndString).replace(/^(\s+)/, '($1)?')
|
||||
commentEndRegex = new OnigRegExp("(#{commentEndRegexString})(\\s*)$")
|
||||
startMatch = commentStartRegex.search(buffer.lineForRow(start))
|
||||
endMatch = commentEndRegex.search(buffer.lineForRow(end))
|
||||
if startMatch and endMatch
|
||||
buffer.transact ->
|
||||
columnStart = startMatch[1].length
|
||||
columnEnd = columnStart + startMatch[2].length
|
||||
buffer.change([[start, columnStart], [start, columnEnd]], "")
|
||||
|
||||
endLength = buffer.lineLengthForRow(end) - endMatch[2].length
|
||||
endColumn = endLength - endMatch[1].length
|
||||
buffer.change([[end, endColumn], [end, endLength]], "")
|
||||
else
|
||||
@editSession.buffer.insert([row, 0], commentString)
|
||||
buffer.transact ->
|
||||
buffer.insert([start, 0], commentStartString)
|
||||
buffer.insert([end, buffer.lineLengthForRow(end)], commentEndString)
|
||||
else
|
||||
if shouldUncomment
|
||||
for row in [start..end]
|
||||
if match = commentStartRegex.search(buffer.lineForRow(row))
|
||||
columnStart = match[1].length
|
||||
columnEnd = columnStart + match[2].length
|
||||
buffer.change([[row, columnStart], [row, columnEnd]], "")
|
||||
else
|
||||
for row in [start..end]
|
||||
buffer.insert([row, 0], commentStartString)
|
||||
|
||||
doesBufferRowStartFold: (bufferRow) ->
|
||||
return false if @editSession.isBufferRowBlank(bufferRow)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
_ = require 'underscore'
|
||||
fs = require 'fs'
|
||||
plist = require 'plist'
|
||||
$ = require 'jquery'
|
||||
|
||||
TextMateGrammar = require 'text-mate-grammar'
|
||||
|
||||
@@ -23,7 +24,10 @@ class TextMateBundle
|
||||
@bundles.push(bundle)
|
||||
|
||||
for scopeSelector, preferences of bundle.getPreferencesByScopeSelector()
|
||||
@preferencesByScopeSelector[scopeSelector] = preferences
|
||||
if @preferencesByScopeSelector[scopeSelector]?
|
||||
_.extend(@preferencesByScopeSelector[scopeSelector], preferences)
|
||||
else
|
||||
@preferencesByScopeSelector[scopeSelector] = preferences
|
||||
|
||||
for grammar in bundle.grammars
|
||||
@grammars.push(grammar)
|
||||
@@ -32,11 +36,17 @@ class TextMateBundle
|
||||
@grammarsByScopeName[grammar.scopeName] = grammar
|
||||
|
||||
@grammarForFilePath: (filePath) ->
|
||||
return @grammarsByFileType["txt"] unless filePath
|
||||
|
||||
extension = fs.extension(filePath)?[1...]
|
||||
if filePath and extension.length == 0
|
||||
extension = fs.base(filePath)
|
||||
|
||||
@grammarsByFileType[extension] or @grammarByShebang(filePath) or @grammarsByFileType["txt"]
|
||||
@grammarsByFileType[extension] or @grammarByShebang(filePath) or @grammarByFileTypeSuffix(filePath) or @grammarsByFileType["txt"]
|
||||
|
||||
@grammarByFileTypeSuffix: (filePath) ->
|
||||
for fileType, grammar of @grammarsByFileType
|
||||
return grammar if _.endsWith(filePath, fileType)
|
||||
|
||||
@grammarByShebang: (filePath) ->
|
||||
try
|
||||
@@ -52,9 +62,15 @@ class TextMateBundle
|
||||
@getPreferenceInScope: (scopeSelector, preferenceName) ->
|
||||
@preferencesByScopeSelector[scopeSelector]?[preferenceName]
|
||||
|
||||
@lineCommentStringForScope: (scope) ->
|
||||
shellVariables = @getPreferenceInScope(scope, 'shellVariables')
|
||||
(_.find shellVariables, ({name}) -> name == "TM_COMMENT_START")?['value']
|
||||
@getPreferenceValueInScope: (scope, preferenceName, valueName) ->
|
||||
values = @getPreferenceInScope(scope, preferenceName)
|
||||
(_.find values, ({name}) -> name is valueName)?['value']
|
||||
|
||||
@lineCommentStartStringForScope: (scope) ->
|
||||
@getPreferenceValueInScope(scope, 'shellVariables', 'TM_COMMENT_START')
|
||||
|
||||
@lineCommentEndStringForScope: (scope) ->
|
||||
@getPreferenceValueInScope(scope, 'shellVariables', 'TM_COMMENT_END')
|
||||
|
||||
@indentRegexForScope: (scope) ->
|
||||
if source = @getPreferenceInScope(scope, 'increaseIndentPattern')
|
||||
@@ -91,7 +107,11 @@ class TextMateBundle
|
||||
console.warn "Failed to parse preference at path '#{preferencePath}'", e
|
||||
else
|
||||
{ scope, settings } = data[0]
|
||||
preferencesByScopeSelector[scope] = _.extend(preferencesByScopeSelector[scope] ? {}, settings)
|
||||
return unless scope
|
||||
for scope in scope.split(',')
|
||||
scope = $.trim(scope)
|
||||
continue unless scope
|
||||
preferencesByScopeSelector[scope] = _.extend(preferencesByScopeSelector[scope] ? {}, settings)
|
||||
|
||||
preferencesByScopeSelector
|
||||
|
||||
@@ -100,4 +120,3 @@ class TextMateBundle
|
||||
|
||||
getPreferencesPath: ->
|
||||
fs.join(@path, "Preferences")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user