mirror of
https://github.com/atom/atom.git
synced 2026-01-24 14:28:14 -05:00
Remove some text editor ivars that are redundant w/ display layer properties
This commit is contained in:
@@ -3,6 +3,7 @@ path = require 'path'
|
||||
temp = require 'temp'
|
||||
clipboard = require '../src/safe-clipboard'
|
||||
TextEditor = require '../src/text-editor'
|
||||
TextBuffer = require 'text-buffer'
|
||||
|
||||
describe "TextEditor", ->
|
||||
[buffer, editor, lineLengths] = []
|
||||
@@ -41,7 +42,7 @@ describe "TextEditor", ->
|
||||
it "restores the editor's layout configuration", ->
|
||||
editor.update({
|
||||
softTabs: true
|
||||
atomicSoftTabs: true
|
||||
atomicSoftTabs: false
|
||||
tabLength: 12
|
||||
softWrapped: true
|
||||
softWrapAtPreferredLineLength: true
|
||||
@@ -51,7 +52,16 @@ describe "TextEditor", ->
|
||||
editorWidthInChars: 120
|
||||
})
|
||||
|
||||
editor2 = TextEditor.deserialize(editor.serialize(), atom)
|
||||
# Force buffer and display layer to be deserialized as well, rather than
|
||||
# reusing the same buffer instance
|
||||
editor2 = TextEditor.deserialize(editor.serialize(), {
|
||||
assert: atom.assert,
|
||||
clipboard: atom.clipboard,
|
||||
textEditors: atom.textEditors,
|
||||
project: {
|
||||
bufferForIdSync: (id) -> TextBuffer.deserialize(editor.buffer.serialize())
|
||||
}
|
||||
})
|
||||
|
||||
expect(editor2.getSoftTabs()).toBe(editor.getSoftTabs())
|
||||
expect(editor2.hasAtomicSoftTabs()).toBe(editor.hasAtomicSoftTabs())
|
||||
|
||||
@@ -128,7 +128,7 @@ class TextEditor extends Model
|
||||
@softWrapped, @decorationManager, @selectionsMarkerLayer, @buffer, suppressCursorCreation,
|
||||
@mini, @placeholderText, lineNumberGutterVisible, @largeFileMode, @clipboard,
|
||||
@assert, grammar, @showInvisibles, @autoHeight, @autoWidth, @scrollPastEnd, @editorWidthInChars,
|
||||
@tokenizedBuffer, @displayLayer, @invisibles, @showIndentGuide, @softWrapHangingIndentLength,
|
||||
@tokenizedBuffer, @displayLayer, @invisibles, @showIndentGuide,
|
||||
@softWrapped, @softWrapAtPreferredLineLength, @preferredLineLength
|
||||
} = params
|
||||
|
||||
@@ -156,7 +156,6 @@ class TextEditor extends Model
|
||||
@undoGroupingInterval ?= 300
|
||||
@nonWordCharacters ?= "/\\()\"':,.;<>~!@#$%^&*|+=[]{}`?-…"
|
||||
@softWrapped ?= false
|
||||
@softWrapHangingIndentLength ?= 0
|
||||
@softWrapAtPreferredLineLength ?= false
|
||||
@preferredLineLength ?= 80
|
||||
|
||||
@@ -169,12 +168,12 @@ class TextEditor extends Model
|
||||
invisibles: @getInvisibles(),
|
||||
softWrapColumn: @getSoftWrapColumn(),
|
||||
showIndentGuides: not @isMini() and @doesShowIndentGuide(),
|
||||
atomicSoftTabs: @hasAtomicSoftTabs(),
|
||||
tabLength: @getTabLength(),
|
||||
atomicSoftTabs: params.atomicSoftTabs ? true,
|
||||
tabLength: tabLength,
|
||||
ratioForCharacter: @ratioForCharacter.bind(this),
|
||||
isWrapBoundary: isWrapBoundary,
|
||||
foldCharacter: ZERO_WIDTH_NBSP,
|
||||
softWrapHangingIndent: @getSoftWrapHangingIndentLength()
|
||||
softWrapHangingIndent: params.softWrapHangingIndentLength ? 0
|
||||
}
|
||||
|
||||
if @displayLayer?
|
||||
@@ -238,8 +237,7 @@ class TextEditor extends Model
|
||||
@softTabs = value
|
||||
|
||||
when 'atomicSoftTabs'
|
||||
if value isnt @atomicSoftTabs
|
||||
@atomicSoftTabs = value
|
||||
if value isnt @displayLayer.atomicSoftTabs
|
||||
displayLayerParams.atomicSoftTabs = value
|
||||
|
||||
when 'tabLength'
|
||||
@@ -254,8 +252,7 @@ class TextEditor extends Model
|
||||
@emitter.emit 'did-change-soft-wrapped', @isSoftWrapped()
|
||||
|
||||
when 'softWrapHangingIndentLength'
|
||||
if value isnt @softWrapHangingIndentLength
|
||||
@softWrapHangingIndentLength = value
|
||||
if value isnt @displayLayer.softWrapHangingIndent
|
||||
displayLayerParams.softWrapHangingIndent = value
|
||||
|
||||
when 'softWrapAtPreferredLineLength'
|
||||
@@ -360,8 +357,10 @@ class TextEditor extends Model
|
||||
firstVisibleScreenRow: @getFirstVisibleScreenRow()
|
||||
firstVisibleScreenColumn: @getFirstVisibleScreenColumn()
|
||||
|
||||
@id, @softTabs, @atomicSoftTabs, @tabLength, @softWrapped,
|
||||
@softWrapHangingIndentLength, @softWrapAtPreferredLineLength,
|
||||
atomicSoftTabs: @displayLayer.atomicSoftTabs
|
||||
softWrapHangingIndentLength: @displayLayer.softWrapHangingIndent
|
||||
|
||||
@id, @softTabs, @tabLength, @softWrapped, @softWrapAtPreferredLineLength,
|
||||
@preferredLineLength, @mini, @editorWidthInChars, @width, @largeFileMode,
|
||||
@registered, @invisibles, @showInvisibles, @showIndentGuide
|
||||
}
|
||||
@@ -2825,7 +2824,7 @@ class TextEditor extends Model
|
||||
setSoftTabs: (@softTabs) -> @update({softTabs})
|
||||
|
||||
# Returns a {Boolean} indicating whether atomic soft tabs are enabled for this editor.
|
||||
hasAtomicSoftTabs: -> @atomicSoftTabs
|
||||
hasAtomicSoftTabs: -> @displayLayer.atomicSoftTabs
|
||||
|
||||
# Essential: Toggle soft tabs for this editor
|
||||
toggleSoftTabs: -> @setSoftTabs(not @getSoftTabs())
|
||||
@@ -2852,7 +2851,7 @@ class TextEditor extends Model
|
||||
|
||||
doesShowIndentGuide: -> @showIndentGuide and not @mini
|
||||
|
||||
getSoftWrapHangingIndentLength: -> @softWrapHangingIndentLength
|
||||
getSoftWrapHangingIndentLength: -> @displayLayer.softWrapHangingIndent
|
||||
|
||||
# Extended: Determine if the buffer uses hard or soft tabs.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user