mirror of
https://github.com/pulsar-edit/pulsar.git
synced 2024-09-20 07:28:08 +03:00
Merge branch 'master' into ns-mb-detangle-editor
This commit is contained in:
commit
c5a6e9c697
@ -520,19 +520,6 @@ describe('TextEditorRegistry', function () {
|
||||
expect(editor.getPreferredLineLength()).toBe(80)
|
||||
})
|
||||
|
||||
it('enables or disables back-up-before-save based on the config', async function () {
|
||||
editor.update({backUpBeforeSaving: true})
|
||||
expect(editor.doesBackUpBeforeSaving()).toBe(true)
|
||||
|
||||
atom.config.set('editor.backUpBeforeSaving', false)
|
||||
registry.maintainConfig(editor)
|
||||
await initialPackageActivation
|
||||
expect(editor.doesBackUpBeforeSaving()).toBe(false)
|
||||
|
||||
atom.config.set('editor.backUpBeforeSaving', true)
|
||||
expect(editor.doesBackUpBeforeSaving()).toBe(true)
|
||||
})
|
||||
|
||||
it('enables or disables auto-indent based on the config', async function () {
|
||||
editor.update({autoIndent: true})
|
||||
expect(editor.shouldAutoIndent()).toBe(true)
|
||||
|
@ -1,6 +1,8 @@
|
||||
/** @babel */
|
||||
/* eslint-env jasmine */
|
||||
|
||||
import path from 'path'
|
||||
import temp from 'temp'
|
||||
import child_process from 'child_process'
|
||||
import {updateProcessEnv, shouldGetEnvFromShell} from '../src/update-process-env'
|
||||
import dedent from 'dedent'
|
||||
@ -44,6 +46,42 @@ describe('updateProcessEnv(launchEnv)', function () {
|
||||
// with another object.
|
||||
expect(process.env).toBe(initialProcessEnv)
|
||||
})
|
||||
|
||||
it('allows ATOM_HOME to be overwritten only if the new value is a valid path', function () {
|
||||
newAtomHomePath = temp.mkdirSync('atom-home')
|
||||
|
||||
process.env = {
|
||||
WILL_BE_DELETED: 'hi',
|
||||
NODE_ENV: 'the-node-env',
|
||||
NODE_PATH: '/the/node/path',
|
||||
ATOM_HOME: '/the/atom/home'
|
||||
}
|
||||
|
||||
updateProcessEnv({PWD: '/the/dir'})
|
||||
expect(process.env).toEqual({
|
||||
PWD: '/the/dir',
|
||||
NODE_ENV: 'the-node-env',
|
||||
NODE_PATH: '/the/node/path',
|
||||
ATOM_HOME: '/the/atom/home'
|
||||
})
|
||||
|
||||
updateProcessEnv({PWD: '/the/dir', ATOM_HOME: path.join(newAtomHomePath, 'non-existent')})
|
||||
expect(process.env).toEqual({
|
||||
PWD: '/the/dir',
|
||||
NODE_ENV: 'the-node-env',
|
||||
NODE_PATH: '/the/node/path',
|
||||
ATOM_HOME: '/the/atom/home'
|
||||
})
|
||||
|
||||
|
||||
updateProcessEnv({PWD: '/the/dir', ATOM_HOME: newAtomHomePath})
|
||||
expect(process.env).toEqual({
|
||||
PWD: '/the/dir',
|
||||
NODE_ENV: 'the-node-env',
|
||||
NODE_PATH: '/the/node/path',
|
||||
ATOM_HOME: newAtomHomePath
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('when the launch environment does not come from a shell', function () {
|
||||
|
@ -232,10 +232,6 @@ module.exports =
|
||||
default: true
|
||||
title: 'Confirm Checkout HEAD Revision'
|
||||
description: 'Show confirmation dialog when checking out the HEAD revision and discarding changes to current file since last commit.'
|
||||
backUpBeforeSaving:
|
||||
type: 'boolean'
|
||||
default: false
|
||||
description: 'Ensure file contents aren\'t lost if there is an I/O error during save by making a temporary backup copy.'
|
||||
invisibles:
|
||||
type: 'object'
|
||||
description: 'A hash of characters Atom will use to render whitespace characters. Keys are whitespace character types, values are rendered characters (use value false to turn off individual whitespace character types).'
|
||||
|
@ -16,7 +16,6 @@ const EDITOR_PARAMS_BY_SETTING_KEY = [
|
||||
['editor.softWrapHangingIndent', 'softWrapHangingIndentLength'],
|
||||
['editor.softWrapAtPreferredLineLength', 'softWrapAtPreferredLineLength'],
|
||||
['editor.preferredLineLength', 'preferredLineLength'],
|
||||
['editor.backUpBeforeSaving', 'backUpBeforeSaving'],
|
||||
['editor.autoIndent', 'autoIndent'],
|
||||
['editor.autoIndentOnPaste', 'autoIndentOnPaste'],
|
||||
['editor.scrollPastEnd', 'scrollPastEnd'],
|
||||
|
@ -150,7 +150,6 @@ class TextEditor extends Model
|
||||
@showInvisibles ?= true
|
||||
@softTabs ?= true
|
||||
tabLength ?= 2
|
||||
@backUpBeforeSaving ?= false
|
||||
@autoIndent ?= true
|
||||
@autoIndentOnPaste ?= true
|
||||
@undoGroupingInterval ?= 300
|
||||
@ -220,9 +219,6 @@ class TextEditor extends Model
|
||||
when 'nonWordCharacters'
|
||||
@nonWordCharacters = value
|
||||
|
||||
when 'backUpBeforeSaving'
|
||||
@backUpBeforeSaving = value
|
||||
|
||||
when 'scrollSensitivity'
|
||||
@scrollSensitivity = value
|
||||
|
||||
@ -851,19 +847,17 @@ class TextEditor extends Model
|
||||
Section: File Operations
|
||||
###
|
||||
|
||||
doesBackUpBeforeSaving: -> @backUpBeforeSaving
|
||||
|
||||
# Essential: Saves the editor's text buffer.
|
||||
#
|
||||
# See {TextBuffer::save} for more details.
|
||||
save: -> @buffer.save(backup: @backUpBeforeSaving)
|
||||
save: -> @buffer.save()
|
||||
|
||||
# Essential: Saves the editor's text buffer as the given path.
|
||||
#
|
||||
# See {TextBuffer::saveAs} for more details.
|
||||
#
|
||||
# * `filePath` A {String} path.
|
||||
saveAs: (filePath) -> @buffer.saveAs(filePath, backup: @backUpBeforeSaving)
|
||||
saveAs: (filePath) -> @buffer.saveAs(filePath)
|
||||
|
||||
# Determine whether the user should be prompted to save before closing
|
||||
# this editor.
|
||||
|
@ -1,5 +1,6 @@
|
||||
/** @babel */
|
||||
|
||||
import fs from 'fs'
|
||||
import {spawnSync} from 'child_process'
|
||||
|
||||
const ENVIRONMENT_VARIABLES_TO_PRESERVE = new Set([
|
||||
@ -37,6 +38,10 @@ function updateProcessEnv (launchEnv) {
|
||||
process.env[key] = envToAssign[key]
|
||||
}
|
||||
}
|
||||
|
||||
if (envToAssign.ATOM_HOME && fs.existsSync(envToAssign.ATOM_HOME)) {
|
||||
process.env.ATOM_HOME = envToAssign.ATOM_HOME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user