mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
detect indentation, tabs vs spaces
This commit is contained in:
@@ -105,8 +105,18 @@ class Editor extends Pane
|
||||
newSession: (code) ->
|
||||
doc = new EditSession code or ''
|
||||
doc.setUndoManager new UndoManager
|
||||
doc.setUseSoftTabs useSoftTabs = @usesSoftTabs code
|
||||
doc.setTabSize if useSoftTabs then @guessTabSize code else 8
|
||||
doc
|
||||
|
||||
usesSoftTabs: (code) ->
|
||||
not /^\t/m.test code or @code()
|
||||
|
||||
guessTabSize: (code) ->
|
||||
# * ignores indentation of css/js block comments
|
||||
match = /^( +)[^*]/im.exec code || @code()
|
||||
match?[1].length or 2
|
||||
|
||||
copy: ->
|
||||
editor = @ace
|
||||
text = editor.getSession().doc.getTextRange editor.getSelectionRange()
|
||||
|
||||
Reference in New Issue
Block a user