mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Don't auto-indent ff a grammar doesn't have an indent/outdent regex
This commit is contained in:
@@ -95,7 +95,8 @@ class LanguageMode
|
||||
|
||||
precedingLine = @editSession.lineForBufferRow(precedingRow)
|
||||
scopes = @tokenizedBuffer.scopesForPosition([precedingRow, Infinity])
|
||||
increaseIndentPattern = new OnigRegExp(TextMateBundle.getPreferenceInScope(scopes[0], 'increaseIndentPattern'))
|
||||
increaseIndentPattern = TextMateBundle.indentRegexForScope(scopes[0])
|
||||
return unless increaseIndentPattern
|
||||
|
||||
currentIndentation = @buffer.indentationForRow(bufferRow)
|
||||
desiredIndentation = @buffer.indentationForRow(precedingRow)
|
||||
@@ -105,8 +106,10 @@ class LanguageMode
|
||||
|
||||
autoDecreaseIndentForBufferRow: (bufferRow) ->
|
||||
scopes = @tokenizedBuffer.scopesForPosition([bufferRow, 0])
|
||||
increaseIndentPattern = new OnigRegExp(TextMateBundle.getPreferenceInScope(scopes[0], 'increaseIndentPattern'))
|
||||
decreaseIndentPattern = new OnigRegExp(TextMateBundle.getPreferenceInScope(scopes[0], 'decreaseIndentPattern'))
|
||||
increaseIndentPattern = TextMateBundle.indentRegexForScope(scopes[0])
|
||||
decreaseIndentPattern = TextMateBundle.outdentRegexForScope(scopes[0])
|
||||
return unless increaseIndentPattern and decreaseIndentPattern
|
||||
|
||||
line = @buffer.lineForRow(bufferRow)
|
||||
return unless decreaseIndentPattern.test(line)
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ ChildProcess = require 'child-process'
|
||||
module.exports =
|
||||
class Project
|
||||
tabText: ' '
|
||||
autoIndent: false
|
||||
autoIndent: true
|
||||
softTabs: true
|
||||
softWrap: false
|
||||
rootDirectory: null
|
||||
|
||||
@@ -4,7 +4,6 @@ plist = require 'plist'
|
||||
|
||||
TextMateGrammar = require 'text-mate-grammar'
|
||||
|
||||
|
||||
module.exports =
|
||||
class TextMateBundle
|
||||
@grammarsByFileType: {}
|
||||
@@ -30,12 +29,20 @@ class TextMateBundle
|
||||
@grammarsByFileType[extension] or @grammarsByFileType["txt"]
|
||||
|
||||
@getPreferenceInScope: (scopeSelector, preferenceName) ->
|
||||
@preferencesByScopeSelector[scopeSelector][preferenceName]
|
||||
@preferencesByScopeSelector[scopeSelector]?[preferenceName]
|
||||
|
||||
@lineCommentStringForScope: (scope) ->
|
||||
shellVariables = @getPreferenceInScope(scope, 'shellVariables')
|
||||
lineComment = (_.find shellVariables, ({name}) -> name == "TM_COMMENT_START")['value']
|
||||
|
||||
@indentRegexForScope: (scope) ->
|
||||
if source = @getPreferenceInScope(scope, 'increaseIndentPattern')
|
||||
new OnigRegExp(source)
|
||||
|
||||
@outdentRegexForScope: (scope) ->
|
||||
if source = @getPreferenceInScope(scope, 'decreaseIndentPattern')
|
||||
new OnigRegExp(source)
|
||||
|
||||
grammars: null
|
||||
|
||||
constructor: (@path) ->
|
||||
|
||||
Reference in New Issue
Block a user