Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #11368 from adobe/prashant/open-split-view-squashe…
Browse files Browse the repository at this point in the history
…d-commits

Opening preferences brackets.json in split view along with default preferences
  • Loading branch information
nethip committed Jul 10, 2015
2 parents 796b870 + 9154e74 commit 6a20586
Show file tree
Hide file tree
Showing 6 changed files with 601 additions and 57 deletions.
22 changes: 15 additions & 7 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,13 @@ define(function (require, exports, module) {
},
whenOpening: {
type: "boolean",
description: Strings.DESCRIPTION_CLOSE_TAGS_WHEN_OPENING
description: Strings.DESCRIPTION_CLOSE_TAGS_WHEN_OPENING,
initial: true
},
whenClosing: {
type: "boolean",
description: Strings.DESCRIPTION_CLOSE_TAGS_WHEN_CLOSING
description: Strings.DESCRIPTION_CLOSE_TAGS_WHEN_CLOSING,
initial: true
},
indentTags: {
type: "array",
Expand All @@ -159,11 +161,13 @@ define(function (require, exports, module) {
keys: {
showToken: {
type: "boolean",
description: Strings.DESCRIPTION_HIGHLIGHT_MATCHES_SHOW_TOKEN
description: Strings.DESCRIPTION_HIGHLIGHT_MATCHES_SHOW_TOKEN,
initial: false
},
wordsOnly: {
type: "boolean",
description: Strings.DESCRIPTION_HIGHLIGHT_MATCHES_WORDS_ONLY
description: Strings.DESCRIPTION_HIGHLIGHT_MATCHES_WORDS_ONLY,
initial: false
}
}
});
Expand Down Expand Up @@ -278,10 +282,13 @@ define(function (require, exports, module) {
* @param {!jQueryObject|DomNode} container Container to add the editor to.
* @param {{startLine: number, endLine: number}=} range If specified, range of lines within the document
* to display in this editor. Inclusive.
* @param {!Object} options If specified, contains editor options that can be passed to CodeMirror
*/
function Editor(document, makeMasterEditor, container, range) {
function Editor(document, makeMasterEditor, container, range, options) {
var self = this;


var isReadOnly = options && options.isReadOnly;

_instances.push(this);

// Attach to document: add ref & handlers
Expand Down Expand Up @@ -384,7 +391,8 @@ define(function (require, exports, module) {
showCursorWhenSelecting : currentOptions[SHOW_CURSOR_SELECT],
smartIndent : currentOptions[SMART_INDENT],
styleActiveLine : currentOptions[STYLE_ACTIVE_LINE],
tabSize : currentOptions[TAB_SIZE]
tabSize : currentOptions[TAB_SIZE],
readOnly : isReadOnly
});

// Can't get CodeMirror's focused state without searching for
Expand Down
23 changes: 15 additions & 8 deletions src/editor/EditorManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ define(function (require, exports, module) {
* @param {!jQueryObject} container Container to add the editor to.
* @param {{startLine: number, endLine: number}=} range If specified, range of lines within the document
* to display in this editor. Inclusive.
* @param {!Object} editorOptions If specified, contains editor options that can be passed to CodeMirror
* @return {Editor} the newly created editor.
*/
function _createEditorForDocument(doc, makeMasterEditor, container, range) {
var editor = new Editor(doc, makeMasterEditor, container, range);
function _createEditorForDocument(doc, makeMasterEditor, container, range, editorOptions) {
var editor = new Editor(doc, makeMasterEditor, container, range, editorOptions);

editor.on("focus", function () {
_notifyActiveEditorChanged(editor);
Expand Down Expand Up @@ -471,11 +472,13 @@ define(function (require, exports, module) {
* Semi-private: should only be called within this module or by Document.
* @param {!Document} document Document whose main/full Editor to create
* @param {!Pane} pane Pane in which the editor will be hosted
* @param {!Object} editorOptions If specified, contains editor options that
* can be passed to CodeMirror
* @return {!Editor}
*/
function _createFullEditorForDocument(document, pane) {
function _createFullEditorForDocument(document, pane, editorOptions) {
// Create editor; make it initially invisible
var editor = _createEditorForDocument(document, true, pane.$content);
var editor = _createEditorForDocument(document, true, pane.$content, undefined, editorOptions);
editor.setVisible(false);
pane.addView(editor);
exports.trigger("_fullEditorCreatedForDocument", document, editor, pane.id);
Expand Down Expand Up @@ -530,9 +533,11 @@ define(function (require, exports, module) {
* Create and/or show the editor for the specified document
* @param {!Document} document - document to edit
* @param {!Pane} pane - pane to show it in
* @param {!Object} editorOptions - If specified, contains
* editor options that can be passed to CodeMirror
* @private
*/
function _showEditor(document, pane) {
function _showEditor(document, pane, editorOptions) {
// Ensure a main editor exists for this document to show in the UI
var createdNewEditor = false,
editor = document._masterEditor;
Expand All @@ -545,7 +550,7 @@ define(function (require, exports, module) {
}

// Editor doesn't exist: populate a new Editor with the text
editor = _createFullEditorForDocument(document, pane);
editor = _createFullEditorForDocument(document, pane, editorOptions);
createdNewEditor = true;
} else if (editor.$el.parent()[0] !== pane.$content[0]) {
// editor does exist but is not a child of the pane so add it to the
Expand Down Expand Up @@ -618,13 +623,15 @@ define(function (require, exports, module) {
* Opens the specified document in the given pane
* @param {!Document} doc - the document to open
* @param {!Pane} pane - the pane to open the document in
* @param {!Object} editorOptions - If specified, contains
* editor options that can be passed to CodeMirror
* @return {boolean} true if the file can be opened, false if not
*/
function openDocument(doc, pane) {
function openDocument(doc, pane, editorOptions) {
var perfTimerName = PerfUtils.markStart("EditorManager.openDocument():\t" + (!doc || doc.file.fullPath));

if (doc && pane) {
_showEditor(doc, pane);
_showEditor(doc, pane, editorOptions);
}

PerfUtils.addMeasurement(perfTimerName);
Expand Down
Loading

0 comments on commit 6a20586

Please sign in to comment.