mirror of
https://github.com/atom/atom.git
synced 2026-02-09 14:15:24 -05:00
All specs pass w/ TextMateGrammar for tokenization (auto-indent disabled)
This commit is contained in:
@@ -29,7 +29,7 @@ class EditSession
|
||||
anchorRanges: null
|
||||
cursors: null
|
||||
selections: null
|
||||
autoIndent: true
|
||||
autoIndent: false # TODO: re-enabled auto-indent after fixing the rest of tokenization
|
||||
softTabs: true
|
||||
softWrap: false
|
||||
|
||||
@@ -139,10 +139,7 @@ class EditSession
|
||||
indent: ->
|
||||
currentRow = @getCursorBufferPosition().row
|
||||
if @getSelection().isEmpty()
|
||||
whitespaceMatch = @lineForBufferRow(currentRow).match /^\s*$/
|
||||
if @autoIndent and whitespaceMatch
|
||||
@autoIndentRow(currentRow)
|
||||
else if @softTabs
|
||||
if @softTabs
|
||||
@insertText(@tabText)
|
||||
else
|
||||
@insertText('\t')
|
||||
|
||||
@@ -800,7 +800,7 @@ class Editor extends View
|
||||
@raw ' ' if line.text == ''
|
||||
else
|
||||
for token in line.tokens
|
||||
@span { class: token.type.replace('.', ' ') }, token.value
|
||||
@span { class: token.getCssClassString() }, token.value
|
||||
|
||||
insertLineElements: (row, lineElements) ->
|
||||
@spliceLineElements(row, 0, lineElements)
|
||||
|
||||
@@ -10,21 +10,18 @@ ChildProcess = require 'child-process'
|
||||
|
||||
module.exports =
|
||||
class Project
|
||||
tabText: ' '
|
||||
autoIndent: false
|
||||
softTabs: true
|
||||
softWrap: false
|
||||
rootDirectory: null
|
||||
editSessions: null
|
||||
tabText: null
|
||||
autoIndent: null
|
||||
softTabs: null
|
||||
softWrap: null
|
||||
ignoredPathRegexes: null
|
||||
|
||||
constructor: (path) ->
|
||||
@setPath(path)
|
||||
@editSessions = []
|
||||
@buffers = []
|
||||
@setTabText(' ')
|
||||
@setAutoIndent(true)
|
||||
@setSoftTabs(true)
|
||||
@ignoredPathRegexes = [
|
||||
/\.DS_Store$/
|
||||
/(^|\/)\.git(\/|$)/
|
||||
|
||||
@@ -26,7 +26,7 @@ class TextMateBundle
|
||||
@grammarsByFileType[fileType] = grammar
|
||||
|
||||
@grammarForFileName: (fileName) ->
|
||||
extension = fs.extension(fileName)[1...]
|
||||
extension = fs.extension(fileName)?[1...]
|
||||
@grammarsByFileType[extension] or @grammarsByFileType["txt"]
|
||||
|
||||
@getPreferenceInScope: (scopeSelector, preferenceName) ->
|
||||
|
||||
@@ -98,8 +98,8 @@ class Pattern
|
||||
regex: null
|
||||
captures: null
|
||||
|
||||
constructor: (@grammar, { name, @include, match, begin, end, captures, beginCaptures, endCaptures, patterns, @popRule}) ->
|
||||
@scopeName = name
|
||||
constructor: (@grammar, { name, contentName, @include, match, begin, end, captures, beginCaptures, endCaptures, patterns, @popRule}) ->
|
||||
@scopeName = name ? contentName # TODO: We need special treatment of contentName
|
||||
if match
|
||||
@regex = new OnigRegExp(match)
|
||||
@captures = captures
|
||||
|
||||
@@ -32,3 +32,15 @@ class Token
|
||||
|
||||
buildTabToken: (tabText) ->
|
||||
new Token(value: tabText, scopes: @scopes, bufferDelta: 1, isAtomic: true)
|
||||
|
||||
getCssClassString: ->
|
||||
@cssClassString ?= @getCssClasses().join(' ')
|
||||
|
||||
getCssClasses: ->
|
||||
classes = []
|
||||
for scope in @scopes
|
||||
scopeComponents = scope.split('.')
|
||||
for i in [0...scopeComponents.length]
|
||||
classes.push scopeComponents[0..i].join('-')
|
||||
classes
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ windowAdditions =
|
||||
$(document).on 'keydown', @_handleKeyEvent
|
||||
|
||||
startup: (path) ->
|
||||
TextMateBundle.loadAll()
|
||||
@attachRootView(path)
|
||||
$(window).on 'close', => @close()
|
||||
$(window).on 'beforeunload', =>
|
||||
@@ -31,7 +32,6 @@ windowAdditions =
|
||||
false
|
||||
$(window).focus()
|
||||
atom.windowOpened this
|
||||
TextMateBundle.loadAll()
|
||||
|
||||
shutdown: ->
|
||||
@rootView.deactivate()
|
||||
|
||||
Reference in New Issue
Block a user