Remove cyclic requires

This commit is contained in:
Nathan Sobo 2017-03-10 14:04:27 -07:00 committed by Antonio Scandurra
parent 4ef9d385f3
commit 6bfe08e9b0
2 changed files with 11 additions and 4 deletions

View File

@ -2,10 +2,12 @@ const etch = require('etch')
const {CompositeDisposable} = require('event-kit')
const {Point} = require('text-buffer')
const resizeDetector = require('element-resize-detector')({strategy: 'scroll'})
const TextEditorElement = require('./text-editor-element')
const TextEditor = require('./text-editor')
const {isPairedCharacter} = require('./text-utils')
const $ = etch.dom
let TextEditorElement
const DEFAULT_ROWS_PER_TILE = 6
const NORMAL_WIDTH_CHARACTER = 'x'
const DOUBLE_WIDTH_CHARACTER = '我'
@ -17,7 +19,12 @@ module.exports =
class TextEditorComponent {
constructor (props) {
this.props = props
this.element = props.element || new TextEditorElement()
if (props.element) {
this.element = props.element
} else {
if (!TextEditorElement) TextEditorElement = require('./text-editor-element')
this.element = new TextEditorElement()
}
this.element.initialize(this)
this.virtualNode = $('atom-text-editor')
this.virtualNode.domNode = this.element
@ -1154,7 +1161,6 @@ class TextEditorComponent {
getModel () {
if (!this.props.model) {
const TextEditor = require('./text-editor')
this.props.model = new TextEditor()
this.observeModel()
}

View File

@ -12,7 +12,7 @@ Model = require './model'
Selection = require './selection'
TextMateScopeSelector = require('first-mate').ScopeSelector
GutterContainer = require './gutter-container'
TextEditorComponent = require './text-editor-component'
TextEditorComponent = null
{isDoubleWidthCharacter, isHalfWidthCharacter, isKoreanCharacter, isWrapBoundary} = require './text-utils'
ZERO_WIDTH_NBSP = '\ufeff'
@ -3547,6 +3547,7 @@ class TextEditor extends Model
# Get the Element for the editor.
getElement: ->
TextEditorComponent ?= require('./text-editor-component')
new TextEditorComponent({model: this})
@component.element