Use TextEditor constructor directly
DELETE
lib/build-text-editor.coffee
-TextEditor = null
-module.exports = (params) ->
- if atom.workspace.buildTextEditor?
- atom.workspace.buildTextEditor(params)
- else
- TextEditor ?= require("atom").TextEditor
- new TextEditor(params)

MODIFY
lib/find-view.coffee
lib/find-view.coffee
_ = require 'underscore-plus'
{$, $$$, View, TextEditorView} = require 'atom-space-pen-views'
-{CompositeDisposable} = require 'atom'
+{TextEditor, CompositeDisposable} = require 'atom'
Util = require './project/util'
-buildTextEditor = require './build-text-editor'
module.exports =
class FindView extends View
@content: (model, {findBuffer, replaceBuffer}) ->
- findEditor = buildTextEditor
+ findEditor = new TextEditor
mini: true
tabLength: 2
softTabs: true
@@ -15,7 +14,7 @@ class FindView extends View
buffer: findBuffer
placeholderText: 'Find in current buffer'
- replaceEditor = buildTextEditor
+ replaceEditor = new TextEditor
mini: true
tabLength: 2
softTabs: true

MODIFY
lib/project-find-view.coffee
lib/project-find-view.coffee
fs = require 'fs-plus'
path = require 'path'
_ = require 'underscore-plus'
-{Disposable, CompositeDisposable} = require 'atom'
+{TextEditor, Disposable, CompositeDisposable} = require 'atom'
{$, $$$, View, TextEditorView} = require 'atom-space-pen-views'
Util = require './project/util'
ResultsModel = require './project/results-model'
ResultsPaneView = require './project/results-pane'
-buildTextEditor = require './build-text-editor'
-
module.exports =
class ProjectFindView extends View
@content: (model, {findBuffer, replaceBuffer, pathsBuffer}) ->
- findEditor = buildTextEditor
+ findEditor = new TextEditor
mini: true
tabLength: 2
softTabs: true
@@ -21,7 +19,7 @@ class ProjectFindView extends View
buffer: findBuffer
placeholderText: 'Find in project'
- replaceEditor = buildTextEditor
+ replaceEditor = new TextEditor
mini: true
tabLength: 2
softTabs: true
@@ -29,7 +27,7 @@ class ProjectFindView extends View
buffer: replaceBuffer
placeholderText: 'Replace in project'
- pathsEditor = buildTextEditor
+ pathsEditor = new TextEditor
mini: true
tabLength: 2
softTabs: true

MODIFY
spec/buffer-search-spec.coffee
spec/buffer-search-spec.coffee
BufferSearch = require '../lib/buffer-search'
FindOptions = require '../lib/find-options'
-buildTextEditor = require '../lib/build-text-editor'
+{TextEditor} = require 'atom'
describe "BufferSearch", ->
[model, editor, markersListener, currentResultListener] = []
beforeEach ->
- editor = buildTextEditor()
+ editor = new TextEditor()
spyOn(editor, 'scanInBufferRange').andCallThrough()
editor.setText """
@@ -465,7 +465,7 @@ describe "BufferSearch", ->
for marker in layer1.findMarkers()
expect(editor.getTextInBufferRange(marker.getBufferRange())).toMatch /a+/
- editor2 = buildTextEditor()
+ editor2 = new TextEditor()
model.setEditor(editor2)
layer2 = model.resultsMarkerLayerForTextEditor(editor2)

MODIFY
spec/find-view-spec.coffee
spec/find-view-spec.coffee
@@ -819,13 +819,8 @@ describe 'FindView', ->
newEditor = null
waitsForPromise ->
- opener =
- if atom.workspace.buildTextEditor?
- atom.workspace.open('sample.coffee', activateItem: false)
- else
- atom.project.open('sample.coffee')
-
- opener.then (o) -> newEditor = o
+ atom.workspace.open('sample.coffee', activateItem: false).then (o) ->
+ newEditor = o
runs ->
newEditor = atom.workspace.paneForItem(editor).splitRight(items: [newEditor]).getActiveItem()

Use TextEditor constructor directly