mirror of
https://github.com/atom/atom.git
synced 2026-01-26 23:38:48 -05:00
Move handling of undoGroupingInterval to TextEditorRegistry
This commit is contained in:
@@ -3909,7 +3909,7 @@ describe('TextEditorComponent', function () {
|
||||
spyOn(Date, 'now').andCallFake(function () {
|
||||
return currentTime
|
||||
})
|
||||
atom.config.set('editor.undoGroupingInterval', 100)
|
||||
editor.setUndoGroupingInterval(100)
|
||||
editor.setText('')
|
||||
componentNode.dispatchEvent(buildTextInputEvent({
|
||||
data: 'x',
|
||||
|
||||
@@ -383,5 +383,16 @@ describe('TextEditorRegistry', function () {
|
||||
atom.config.set('editor.scrollPastEnd', true)
|
||||
expect(editor.getScrollPastEnd()).toBe(true)
|
||||
})
|
||||
|
||||
it('sets the undo grouping interval based on the config', function () {
|
||||
expect(editor.getUndoGroupingInterval()).toBe(300)
|
||||
|
||||
atom.config.set('editor.undoGroupingInterval', 600)
|
||||
registry.maintainConfig(editor)
|
||||
expect(editor.getUndoGroupingInterval()).toBe(600)
|
||||
|
||||
atom.config.set('editor.undoGroupingInterval', 300)
|
||||
expect(editor.getUndoGroupingInterval()).toBe(300)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -17,6 +17,7 @@ const EDITOR_SETTER_NAMES_BY_SETTING_KEY = [
|
||||
['editor.autoIndent', 'setAutoIndent'],
|
||||
['editor.autoIndentOnPaste', 'setAutoIndentOnPaste'],
|
||||
['editor.scrollPastEnd', 'setScrollPastEnd'],
|
||||
['editor.undoGroupingInterval', 'setUndoGroupingInterval'],
|
||||
]
|
||||
|
||||
// Experimental: This global registry tracks registered `TextEditors`.
|
||||
|
||||
@@ -153,6 +153,7 @@ class TextEditor extends Model
|
||||
@backUpBeforeSaving ?= false
|
||||
@autoIndent ?= true
|
||||
@autoIndentOnPaste ?= true
|
||||
@undoGroupingInterval ?= 300
|
||||
|
||||
@buffer ?= new TextBuffer
|
||||
@tokenizedBuffer ?= new TokenizedBuffer({
|
||||
@@ -898,7 +899,7 @@ class TextEditor extends Model
|
||||
return false unless @emitWillInsertTextEvent(text)
|
||||
|
||||
groupingInterval = if options.groupUndo
|
||||
@config.get('editor.undoGroupingInterval')
|
||||
@undoGroupingInterval
|
||||
else
|
||||
0
|
||||
|
||||
@@ -3339,6 +3340,10 @@ class TextEditor extends Model
|
||||
|
||||
getScrollPastEnd: -> @scrollPastEnd
|
||||
|
||||
setUndoGroupingInterval: (@undoGroupingInterval) ->
|
||||
|
||||
getUndoGroupingInterval: -> @undoGroupingInterval
|
||||
|
||||
###
|
||||
Section: Event Handlers
|
||||
###
|
||||
|
||||
Reference in New Issue
Block a user