Merge pull request #12924 from atom/as-export-text-editor-ctor

Include `TextEditor` in Atom exports
This commit is contained in:
Nathan Sobo
2016-10-10 07:15:55 -06:00
committed by GitHub
17 changed files with 79 additions and 90 deletions

View File

@@ -3,8 +3,6 @@
import TextBuffer, {Point, Range} from 'text-buffer'
import {File, Directory} from 'pathwatcher'
import {Emitter, Disposable, CompositeDisposable} from 'event-kit'
import Grim from 'grim'
import dedent from 'dedent'
import BufferedNodeProcess from '../src/buffered-node-process'
import BufferedProcess from '../src/buffered-process'
import GitRepository from '../src/git-repository'
@@ -39,25 +37,7 @@ if (process.platform === 'win32') {
// only be exported when not running as a child node process
if (process.type === 'renderer') {
atomExport.Task = require('../src/task')
const TextEditor = (params) => {
return atom.workspace.buildTextEditor(params)
}
TextEditor.prototype = require('../src/text-editor').prototype
Object.defineProperty(atomExport, 'TextEditor', {
enumerable: true,
get () {
Grim.deprecate(dedent`
The \`TextEditor\` constructor is no longer public.
To construct a text editor, use \`atom.workspace.buildTextEditor()\`.
To check if an object is a text editor, use \`atom.workspace.isTextEditor(object)\`.
`)
return TextEditor
}
})
atomExport.TextEditor = require('../src/text-editor')
}
export default atomExport

View File

@@ -1,9 +1,11 @@
TextEditor = require '../src/text-editor'
describe "Selection", ->
[buffer, editor, selection] = []
beforeEach ->
buffer = atom.project.bufferForPathSync('sample.js')
editor = atom.workspace.buildTextEditor(buffer: buffer, tabLength: 2)
editor = new TextEditor({buffer: buffer, tabLength: 2})
selection = editor.getLastSelection()
afterEach ->

View File

@@ -2,6 +2,7 @@
import {it, fit, ffit, fffit, beforeEach, afterEach, conditionPromise} from './async-spec-helpers'
import Grim from 'grim'
import TextEditor from '../src/text-editor'
import TextEditorElement from '../src/text-editor-element'
import _, {extend, flatten, last, toArray} from 'underscore-plus'
@@ -4419,7 +4420,7 @@ describe('TextEditorComponent', function () {
describe('when autoHeight is not assigned on the editor', function () {
it('implicitly assigns autoHeight to true and emits a deprecation warning if the editor has its height assigned via an inline style', function () {
editor = atom.workspace.buildTextEditor()
editor = new TextEditor()
element = editor.getElement()
element.setUpdatedSynchronously(false)
element.style.height = '200px'
@@ -4434,7 +4435,7 @@ describe('TextEditorComponent', function () {
})
it('implicitly assigns autoHeight to true and emits a deprecation warning if the editor has its height assigned via position absolute with an assigned top and bottom', function () {
editor = atom.workspace.buildTextEditor()
editor = new TextEditor()
element = editor.getElement()
element.setUpdatedSynchronously(false)
parentElement = document.createElement('div')

View File

@@ -1,3 +1,4 @@
TextEditor = require '../src/text-editor'
TextEditorElement = require '../src/text-editor-element'
{Disposable} = require 'event-kit'
@@ -33,7 +34,7 @@ describe "TextEditorElement", ->
describe "when the model is assigned", ->
it "adds the 'mini' attribute if .isMini() returns true on the model", ->
element = new TextEditorElement
model = atom.workspace.buildTextEditor(mini: true)
model = new TextEditor({mini: true})
element.setModel(model)
expect(element.hasAttribute('mini')).toBe true
@@ -52,7 +53,7 @@ describe "TextEditorElement", ->
describe "when the editor is detached from the DOM and then reattached", ->
it "does not render duplicate line numbers", ->
editor = atom.workspace.buildTextEditor()
editor = new TextEditor
editor.setText('1\n2\n3')
element = atom.views.getView(editor)
@@ -65,7 +66,7 @@ describe "TextEditorElement", ->
expect(element.shadowRoot.querySelectorAll('.line-number').length).toBe initialCount
it "does not render duplicate decorations in custom gutters", ->
editor = atom.workspace.buildTextEditor()
editor = new TextEditor
editor.setText('1\n2\n3')
editor.addGutter({name: 'test-gutter'})
marker = editor.markBufferRange([[0, 0], [2, 0]])
@@ -200,7 +201,7 @@ describe "TextEditorElement", ->
describe "::getMaxScrollTop", ->
it "returns the maximum scroll top that can be applied to the element", ->
editor = atom.workspace.buildTextEditor()
editor = new TextEditor
editor.setText('1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11\n12\n13\n14\n15\n16')
element = atom.views.getView(editor)
element.style.lineHeight = "10px"

View File

@@ -2,6 +2,7 @@ _ = require 'underscore-plus'
randomWords = require 'random-words'
TextBuffer = require 'text-buffer'
{Point, Range} = TextBuffer
TextEditor = require '../src/text-editor'
TextEditorPresenter = require '../src/text-editor-presenter'
FakeLinesYardstick = require './fake-lines-yardstick'
LineTopIndex = require 'line-top-index'
@@ -18,7 +19,7 @@ describe "TextEditorPresenter", ->
spyOn(window, "clearInterval").andCallFake window.fakeClearInterval
buffer = new TextBuffer(filePath: require.resolve('./fixtures/sample.js'))
editor = atom.workspace.buildTextEditor({buffer})
editor = new TextEditor({buffer})
waitsForPromise -> buffer.load()
afterEach ->
@@ -474,6 +475,7 @@ describe "TextEditorPresenter", ->
waitsForPromise -> atom.packages.activatePackage('language-javascript')
runs ->
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
maxLineLength = editor.getMaxScreenLineLength()
presenter = buildPresenter(contentFrameWidth: 50, baseCharacterWidth: 10)
@@ -758,6 +760,7 @@ describe "TextEditorPresenter", ->
waitsForPromise -> atom.packages.activatePackage('language-javascript')
runs ->
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
editor.setCursorBufferPosition([3, 6])
presenter = buildPresenter()
expect(getState(presenter).hiddenInput.width).toBe 10
@@ -917,6 +920,7 @@ describe "TextEditorPresenter", ->
waitsForPromise -> atom.packages.activatePackage('language-javascript')
runs ->
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
maxLineLength = editor.getMaxScreenLineLength()
presenter = buildPresenter(contentFrameWidth: 50, baseCharacterWidth: 10)
@@ -1264,6 +1268,8 @@ describe "TextEditorPresenter", ->
expectValues lineStateForScreenRow(presenter, 3), {screenRow: 3, tagCodes: editor.screenLineForScreenRow(3).tagCodes}
it "includes the .endOfLineInvisibles if the editor.showInvisibles config option is true", ->
editor.update({showInvisibles: false, invisibles: {eol: 'X'}})
editor.setText("hello\nworld\r\n")
presenter = buildPresenter(explicitHeight: 25, scrollTop: 0, lineHeight: 10)
expect(tagsForCodes(presenter, lineStateForScreenRow(presenter, 0).tagCodes).openTags).not.toContain('invisible-character eol')
@@ -1730,6 +1736,7 @@ describe "TextEditorPresenter", ->
atom.packages.activatePackage('language-javascript')
runs ->
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
editor.setCursorBufferPosition([1, 4])
presenter = buildPresenter(explicitHeight: 20)
@@ -2075,6 +2082,7 @@ describe "TextEditorPresenter", ->
atom.packages.activatePackage('language-javascript')
runs ->
editor.setGrammar(atom.grammars.grammarForScopeName('source.js'))
editor.setSelectedBufferRanges([
[[2, 4], [2, 6]],
])
@@ -3666,7 +3674,7 @@ describe "TextEditorPresenter", ->
performSetup = ->
buffer = new TextBuffer
editor = atom.workspace.buildTextEditor({buffer})
editor = new TextEditor({buffer})
editor.setEditorWidthInChars(80)
presenterParams =
model: editor

View File

@@ -15,15 +15,11 @@ describe('TextEditorRegistry', function () {
registry = new TextEditorRegistry({
assert: atom.assert,
config: atom.config,
clipboard: atom.clipboard,
grammarRegistry: atom.grammars,
packageManager: {deferredActivationHooks: null}
})
editor = new TextEditor({
config: atom.config,
clipboard: atom.clipboard,
})
editor = new TextEditor()
})
afterEach(function () {
@@ -194,10 +190,7 @@ describe('TextEditorRegistry', function () {
it('does not update the editor when config settings change for unrelated scope selectors', async function () {
await atom.packages.activatePackage('language-javascript')
const editor2 = new TextEditor({
config: atom.config,
clipboard: atom.clipboard,
})
const editor2 = new TextEditor()
editor2.setGrammar(atom.grammars.selectGrammar('test.js'))
@@ -224,7 +217,6 @@ describe('TextEditorRegistry', function () {
registry = new TextEditorRegistry({
assert: atom.assert,
config: atom.config,
clipboard: atom.clipboard,
grammarRegistry: atom.grammars,
packageManager: {
deferredActivationHooks: [],
@@ -669,10 +661,7 @@ describe('TextEditorRegistry', function () {
describe('serialization', function () {
it('persists editors\' grammar overrides', async function () {
const editor2 = new TextEditor({
config: atom.config,
clipboard: atom.clipboard,
})
const editor2 = new TextEditor()
await atom.packages.activatePackage('language-c')
await atom.packages.activatePackage('language-html')
@@ -691,7 +680,6 @@ describe('TextEditorRegistry', function () {
const registryCopy = new TextEditorRegistry({
assert: atom.assert,
config: atom.config,
clipboard: atom.clipboard,
grammarRegistry: atom.grammars,
packageManager: {deferredActivationHooks: null}
})

View File

@@ -54,7 +54,6 @@ describe "TextEditor", ->
# 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())
@@ -5525,7 +5524,7 @@ describe "TextEditor", ->
describe "auto height", ->
it "returns true by default but can be customized", ->
editor = atom.workspace.buildTextEditor()
editor = new TextEditor
expect(editor.getAutoHeight()).toBe(true)
editor.update({autoHeight: false})
expect(editor.getAutoHeight()).toBe(false)
@@ -5543,10 +5542,10 @@ describe "TextEditor", ->
describe '.get/setPlaceholderText()', ->
it 'can be created with placeholderText', ->
newEditor = atom.workspace.buildTextEditor(
newEditor = new TextEditor({
mini: true
placeholderText: 'yep'
)
})
expect(newEditor.getPlaceholderText()).toBe 'yep'
it 'models placeholderText and emits an event when changed', ->
@@ -5831,11 +5830,7 @@ describe "TextEditor", ->
atom.packages.activatePackage('language-coffee-script')
it "sets the grammar", ->
editor = new TextEditor({
grammar: atom.grammars.grammarForScopeName('source.coffee')
clipboard: atom.clipboard
})
editor = new TextEditor({grammar: atom.grammars.grammarForScopeName('source.coffee')})
expect(editor.getGrammar().name).toBe 'CoffeeScript'
describe "softWrapAtPreferredLineLength", ->

View File

@@ -1,5 +1,6 @@
path = require 'path'
temp = require 'temp'
TextEditor = require '../src/text-editor'
Workspace = require '../src/workspace'
Project = require '../src/project'
platform = require './spec-helper-platform'
@@ -29,7 +30,7 @@ describe "Workspace", ->
atom.workspace = new Workspace({
config: atom.config, project: atom.project, packageManager: atom.packages,
grammarRegistry: atom.grammars, deserializerManager: atom.deserializers,
notificationManager: atom.notifications, clipboard: atom.clipboard,
notificationManager: atom.notifications,
applicationDelegate: atom.applicationDelegate,
viewRegistry: atom.views, assert: atom.assert.bind(atom),
textEditorRegistry: atom.textEditors
@@ -795,7 +796,7 @@ describe "Workspace", ->
describe "::isTextEditor(obj)", ->
it "returns true when the passed object is an instance of `TextEditor`", ->
expect(workspace.isTextEditor(atom.workspace.buildTextEditor())).toBe(true)
expect(workspace.isTextEditor(new TextEditor)).toBe(true)
expect(workspace.isTextEditor({getText: -> null})).toBe(false)
expect(workspace.isTextEditor(null)).toBe(false)
expect(workspace.isTextEditor(undefined)).toBe(false)
@@ -871,7 +872,7 @@ describe "Workspace", ->
workspace2 = new Workspace({
config: atom.config, project: atom.project, packageManager: atom.packages,
notificationManager: atom.notifications, deserializerManager: atom.deserializers,
clipboard: atom.clipboard, viewRegistry: atom.views, grammarRegistry: atom.grammars,
viewRegistry: atom.views, grammarRegistry: atom.grammars,
applicationDelegate: atom.applicationDelegate, assert: atom.assert.bind(atom),
textEditorRegistry: atom.textEditors
})
@@ -934,7 +935,7 @@ describe "Workspace", ->
workspace2 = new Workspace({
config: atom.config, project: atom.project, packageManager: atom.packages,
notificationManager: atom.notifications, deserializerManager: atom.deserializers,
clipboard: atom.clipboard, viewRegistry: atom.views, grammarRegistry: atom.grammars,
viewRegistry: atom.views, grammarRegistry: atom.grammars,
applicationDelegate: atom.applicationDelegate, assert: atom.assert.bind(atom),
textEditorRegistry: atom.textEditors
})
@@ -1727,7 +1728,7 @@ describe "Workspace", ->
describe "when there's no repository for the editor's file", ->
it "doesn't do anything", ->
editor = atom.workspace.buildTextEditor()
editor = new TextEditor
editor.setText("stuff")
atom.workspace.checkoutHeadRevision(editor)

View File

@@ -28,7 +28,6 @@ ThemeManager = require './theme-manager'
MenuManager = require './menu-manager'
ContextMenuManager = require './context-menu-manager'
CommandInstaller = require './command-installer'
Clipboard = require './clipboard'
Project = require './project'
TitleBar = require './title-bar'
Workspace = require './workspace'
@@ -127,7 +126,7 @@ class AtomEnvironment extends Model
# Call .loadOrCreate instead
constructor: (params={}) ->
{@blobStore, @applicationDelegate, @window, @document, @configDirPath, @enablePersistence, onlyLoadBaseStyleSheets} = params
{@blobStore, @applicationDelegate, @window, @document, @clipboard, @configDirPath, @enablePersistence, onlyLoadBaseStyleSheets} = params
@unloaded = false
@loadTime = null
@@ -182,20 +181,18 @@ class AtomEnvironment extends Model
@packages.setContextMenuManager(@contextMenu)
@packages.setThemeManager(@themes)
@clipboard = new Clipboard()
@project = new Project({notificationManager: @notifications, packageManager: @packages, @config, @applicationDelegate})
@commandInstaller = new CommandInstaller(@getVersion(), @applicationDelegate)
@textEditors = new TextEditorRegistry({
@config, grammarRegistry: @grammars, assert: @assert.bind(this), @clipboard,
@config, grammarRegistry: @grammars, assert: @assert.bind(this),
packageManager: @packages
})
@workspace = new Workspace({
@config, @project, packageManager: @packages, grammarRegistry: @grammars, deserializerManager: @deserializers,
notificationManager: @notifications, @applicationDelegate, @clipboard, viewRegistry: @views, assert: @assert.bind(this),
notificationManager: @notifications, @applicationDelegate, viewRegistry: @views, assert: @assert.bind(this),
textEditorRegistry: @textEditors,
})

View File

@@ -20,16 +20,21 @@ module.exports = ({blobStore}) ->
AtomEnvironment = require './atom-environment'
ApplicationDelegate = require './application-delegate'
Clipboard = require './clipboard'
TextEditor = require './text-editor'
clipboard = new Clipboard
TextEditor.setClipboard(clipboard)
window.atom = new AtomEnvironment({
window, document, blobStore,
window, document, clipboard, blobStore,
applicationDelegate: new ApplicationDelegate,
configDirPath: process.env.ATOM_HOME
enablePersistence: true
configDirPath: process.env.ATOM_HOME,
enablePersistence: true,
env: process.env
})
atom.startEditorWindow().then ->
# Workaround for focus getting cleared upon window creation
windowFocused = ->
window.removeEventListener('focus', windowFocused)

View File

@@ -21,6 +21,8 @@ module.exports = ({blobStore}) ->
{getWindowLoadSettings} = require './window-load-settings-helpers'
AtomEnvironment = require '../src/atom-environment'
ApplicationDelegate = require '../src/application-delegate'
Clipboard = require '../src/clipboard'
TextEditor = require '../src/text-editor'
require '../src/electron-shims'
{testRunnerPath, legacyTestRunnerPath, headless, logFile, testPaths} = getWindowLoadSettings()
@@ -58,11 +60,15 @@ module.exports = ({blobStore}) ->
document.title = "Spec Suite"
clipboard = new Clipboard
TextEditor.setClipboard(clipboard)
testRunner = require(testRunnerPath)
legacyTestRunner = require(legacyTestRunnerPath)
buildDefaultApplicationDelegate = -> new ApplicationDelegate()
buildAtomEnvironment = (params) ->
params = cloneObject(params)
params.clipboard = clipboard unless params.hasOwnProperty("clipboard")
params.blobStore = blobStore unless params.hasOwnProperty("blobStore")
params.onlyLoadBaseStyleSheets = true unless params.hasOwnProperty("onlyLoadBaseStyleSheets")
new AtomEnvironment(params)

View File

@@ -2,6 +2,7 @@
_ = require 'underscore-plus'
{OnigRegExp} = require 'oniguruma'
ScopeDescriptor = require './scope-descriptor'
NullGrammar = require './null-grammar'
module.exports =
class LanguageMode
@@ -245,7 +246,10 @@ class LanguageMode
@suggestedIndentForTokenizedLineAtBufferRow(bufferRow, line, tokenizedLine, options)
suggestedIndentForLineAtBufferRow: (bufferRow, line, options) ->
tokenizedLine = @editor.tokenizedBuffer.buildTokenizedLineForRowWithText(bufferRow, line)
if @editor.largeFileMode or @editor.tokenizedBuffer.grammar is NullGrammar
tokenizedLine = @editor.tokenizedBuffer.buildPlaceholderTokenizedLineForRowWithText(bufferRow, line)
else
tokenizedLine = @editor.tokenizedBuffer.buildTokenizedLineForRowWithText(bufferRow, line)
@suggestedIndentForTokenizedLineAtBufferRow(bufferRow, line, tokenizedLine, options)
suggestedIndentForTokenizedLineAtBufferRow: (bufferRow, line, tokenizedLine, options) ->

View File

@@ -14,7 +14,7 @@ class Selection extends Model
initialScreenRange: null
wordwise: false
constructor: ({@cursor, @marker, @editor, id, @clipboard}) ->
constructor: ({@cursor, @marker, @editor, id}) ->
@emitter = new Emitter
@assignId(id)
@@ -605,7 +605,7 @@ class Selection extends Model
startLevel = @editor.indentLevelForLine(precedingText)
if maintainClipboard
{text: clipboardText, metadata} = @clipboard.readWithMetadata()
{text: clipboardText, metadata} = @editor.constructor.clipboard.readWithMetadata()
metadata ?= {}
unless metadata.selections?
metadata.selections = [{
@@ -618,9 +618,9 @@ class Selection extends Model
indentBasis: startLevel,
fullLine: fullLine
})
@clipboard.write([clipboardText, selectionText].join("\n"), metadata)
@editor.constructor.clipboard.write([clipboardText, selectionText].join("\n"), metadata)
else
@clipboard.write(selectionText, {
@editor.constructor.clipboard.write(selectionText, {
indentBasis: startLevel,
fullLine: fullLine
})

View File

@@ -39,9 +39,8 @@ const GRAMMAR_SELECTION_RANGE = Range(Point.ZERO, Point(10, 0)).freeze()
// done using your editor, be sure to call `dispose` on the returned disposable
// to avoid leaking editors.
export default class TextEditorRegistry {
constructor ({config, grammarRegistry, clipboard, assert, packageManager}) {
constructor ({config, grammarRegistry, assert, packageManager}) {
this.assert = assert
this.clipboard = clipboard
this.config = config
this.grammarRegistry = grammarRegistry
this.scopedSettingsDelegate = new ScopedSettingsDelegate(config)
@@ -109,10 +108,7 @@ export default class TextEditorRegistry {
}
build (params) {
params = Object.assign({
clipboard: this.clipboard,
assert: this.assert
}, params)
params = Object.assign({assert: this.assert}, params)
let scope = null
if (params.buffer) {

View File

@@ -59,6 +59,9 @@ ZERO_WIDTH_NBSP = '\ufeff'
# soft wraps and folds to ensure your code interacts with them correctly.
module.exports =
class TextEditor extends Model
@setClipboard: (clipboard) ->
@clipboard = clipboard
serializationVersion: 1
buffer: null
@@ -114,7 +117,6 @@ class TextEditor extends Model
if state.displayLayer = state.buffer.getDisplayLayer(state.displayLayerId)
state.selectionsMarkerLayer = state.displayLayer.getMarkerLayer(state.selectionsMarkerLayerId)
state.clipboard = atomEnvironment.clipboard
state.assert = atomEnvironment.assert.bind(atomEnvironment)
editor = new this(state)
if state.registered
@@ -123,19 +125,20 @@ class TextEditor extends Model
editor
constructor: (params={}) ->
unless @constructor.clipboard?
throw new Error("Must call TextEditor.setClipboard at least once before creating TextEditor instances")
super
{
@softTabs, @firstVisibleScreenRow, @firstVisibleScreenColumn, initialLine, initialColumn, tabLength,
@softWrapped, @decorationManager, @selectionsMarkerLayer, @buffer, suppressCursorCreation,
@mini, @placeholderText, lineNumberGutterVisible, @largeFileMode, @clipboard,
@mini, @placeholderText, lineNumberGutterVisible, @largeFileMode,
@assert, grammar, @showInvisibles, @autoHeight, @autoWidth, @scrollPastEnd, @editorWidthInChars,
@tokenizedBuffer, @displayLayer, @invisibles, @showIndentGuide,
@softWrapped, @softWrapAtPreferredLineLength, @preferredLineLength
} = params
throw new Error("Must pass a clipboard parameter when constructing TextEditors") unless @clipboard?
@assert ?= (condition) -> condition
@firstVisibleScreenRow ?= 0
@firstVisibleScreenColumn ?= 0
@@ -147,7 +150,7 @@ class TextEditor extends Model
@hasTerminatedPendingState = false
@mini ?= false
@scrollPastEnd ?= true
@scrollPastEnd ?= false
@showInvisibles ?= true
@softTabs ?= true
tabLength ?= 2
@@ -705,7 +708,7 @@ class TextEditor extends Model
suppressCursorCreation: true,
tabLength: @tokenizedBuffer.getTabLength(),
@firstVisibleScreenRow, @firstVisibleScreenColumn,
@clipboard, @assert, displayLayer, grammar: @getGrammar(),
@assert, displayLayer, grammar: @getGrammar(),
@autoWidth, @autoHeight
})
@@ -2718,7 +2721,7 @@ class TextEditor extends Model
# Returns the new {Selection}.
addSelection: (marker, options={}) ->
cursor = @addCursor(marker)
selection = new Selection(Object.assign({editor: this, marker, cursor, @clipboard}, options))
selection = new Selection(Object.assign({editor: this, marker, cursor}, options))
@selections.push(selection)
selectionBufferRange = selection.getBufferRange()
@mergeIntersectingSelections(preserveFolds: options.preserveFolds)
@@ -3127,7 +3130,7 @@ class TextEditor extends Model
#
# * `options` (optional) See {Selection::insertText}.
pasteText: (options={}) ->
{text: clipboardText, metadata} = @clipboard.readWithMetadata()
{text: clipboardText, metadata} = @constructor.clipboard.readWithMetadata()
return false unless @emitWillInsertTextEvent(clipboardText)
metadata ?= {}

View File

@@ -263,11 +263,13 @@ class TokenizedBuffer extends Model
@buildPlaceholderTokenizedLineForRow(row) for row in [startRow..endRow] by 1
buildPlaceholderTokenizedLineForRow: (row) ->
@buildPlaceholderTokenizedLineForRowWithText(row, @buffer.lineForRow(row))
buildPlaceholderTokenizedLineForRowWithText: (row, text) ->
if @grammar isnt NullGrammar
openScopes = [@grammar.startIdForScope(@grammar.scopeName)]
else
openScopes = []
text = @buffer.lineForRow(row)
tags = [text.length]
lineEnding = @buffer.lineEndingForRow(row)
new TokenizedLine({openScopes, text, tags, lineEnding, @tokenIterator})

View File

@@ -28,7 +28,7 @@ class Workspace extends Model
{
@packageManager, @config, @project, @grammarRegistry, @notificationManager,
@clipboard, @viewRegistry, @grammarRegistry, @applicationDelegate, @assert,
@viewRegistry, @grammarRegistry, @applicationDelegate, @assert,
@deserializerManager, @textEditorRegistry
} = params