Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

Commit

Permalink
Remove the texteditor isModified/isReadOnly handling intended for uns…
Browse files Browse the repository at this point in the history
…avable edit buffers as causes issues with vim-mode-plus
  • Loading branch information
damieng authored and kuychaco committed Dec 14, 2017
1 parent 5fcf514 commit 4290fca
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
17 changes: 0 additions & 17 deletions spec/text-editor-spec.js
Expand Up @@ -86,23 +86,6 @@ describe('TextEditor', () => {
}) })
}) })


describe('when the editor is readonly', () => {
it('overrides TextBuffer.isModified to return false', async () => {
const editor = await atom.workspace.open(null, {readOnly: true})
editor.setText('I am altering the buffer, pray I do not alter it any further')
expect(editor.isModified()).toBe(false)
editor.setReadOnly(false)
expect(editor.isModified()).toBe(true)
})
it('clears the readonly status when saved', async () => {
const editor = await atom.workspace.open(null, {readOnly: true})
editor.setText('I am altering the buffer, pray I do not alter it any further')
expect(editor.isReadOnly()).toBe(true)
await editor.saveAs(temp.openSync('was-readonly').path)
expect(editor.isReadOnly()).toBe(false)
})
})

describe('.copy()', () => { describe('.copy()', () => {
it('returns a different editor with the same initial state', () => { it('returns a different editor with the same initial state', () => {
expect(editor.getAutoHeight()).toBeFalsy() expect(editor.getAutoHeight()).toBeFalsy()
Expand Down
8 changes: 1 addition & 7 deletions src/text-editor.js
Expand Up @@ -407,7 +407,6 @@ class TextEditor {
if (this.component != null) { if (this.component != null) {
this.component.scheduleUpdate() this.component.scheduleUpdate()
} }
this.buffer.emitModifiedStatusChanged(this.isModified())
} }
break break


Expand Down Expand Up @@ -568,11 +567,6 @@ class TextEditor {
this.disposables.add(this.buffer.onDidChangeModified(() => { this.disposables.add(this.buffer.onDidChangeModified(() => {
if (!this.hasTerminatedPendingState && this.buffer.isModified()) this.terminatePendingState() if (!this.hasTerminatedPendingState && this.buffer.isModified()) this.terminatePendingState()
})) }))
this.disposables.add(this.buffer.onDidSave(() => {
if (this.isReadOnly()) {
this.setReadOnly(false)
}
}))
} }


terminatePendingState () { terminatePendingState () {
Expand Down Expand Up @@ -1129,7 +1123,7 @@ class TextEditor {
setEncoding (encoding) { this.buffer.setEncoding(encoding) } setEncoding (encoding) { this.buffer.setEncoding(encoding) }


// Essential: Returns {Boolean} `true` if this editor has been modified. // Essential: Returns {Boolean} `true` if this editor has been modified.
isModified () { return this.isReadOnly() ? false : this.buffer.isModified() } isModified () { return this.buffer.isModified() }


// Essential: Returns {Boolean} `true` if this editor has no content. // Essential: Returns {Boolean} `true` if this editor has no content.
isEmpty () { return this.buffer.isEmpty() } isEmpty () { return this.buffer.isEmpty() }
Expand Down

0 comments on commit 4290fca

Please sign in to comment.