Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c52fb15
Add feature. Open line above/below the current line (Ctrl-Enter / Ctr…
zeis Jan 30, 2013
c4ae5c5
Add unit tests for Open Line feature
zeis Jan 31, 2013
056f84a
Improve Open Line feature. Add additional unit tests.
zeis Feb 1, 2013
8d54428
Invert OpenLine shortcuts
zeis Feb 12, 2013
3b87017
Merge branch 'master' of https://github.com/adobe/brackets into openline
zeis Feb 15, 2013
56f678e
Fix OpenLine problem with inline editors.
zeis Feb 15, 2013
3eea8da
Fix OpenLine undo history
zeis Feb 16, 2013
a118ef1
Add few improvements in OpenLine
zeis Feb 17, 2013
6cf215c
Merge upstream updates
zeis Feb 28, 2013
42cd57a
Merge master
zeis Mar 14, 2013
f8832d4
Merge branch 'master' of https://github.com/adobe/brackets into openline
zeis Apr 11, 2013
190d58a
Include TomMalbran's suggestions
zeis Apr 11, 2013
ebd85e2
Merge branch 'master' of https://github.com/adobe/brackets into openline
zeis Apr 18, 2013
9ebbe08
Add special case for last line in inline editor
zeis Apr 18, 2013
6c0ff04
Merge branch 'master' of https://github.com/adobe/brackets into openline
zeis Apr 19, 2013
dd7537a
Include changes to OpenLinecode and new tests
zeis Apr 19, 2013
4de987a
Merge branch 'master' of https://github.com/adobe/brackets into openline
zeis Apr 20, 2013
27321f8
Remove Italian strings for OpenLine. Add little changes to tests.
zeis Apr 20, 2013
5e2d29e
Few cleanups for OpenLine's tests
zeis Apr 20, 2013
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/base-config/keyboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@
"platform": "mac"
}
],
"edit.openLineAbove": [
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These keyboard shortcuts are actually the reverse of what I'd expect. ctrl-enter for open line below and ctrl-shift-enter for open line above. I just fired up Sublime 3 and it agrees with me. From my own usage, I've probably opened lines below 10 times for every time I've opened above...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you on this. I also open lines below more frequently than above. I just kept the same shortcuts as in Visual Studio. I never used Sublime Text.
In the last commit they have been inverted.

"Ctrl-Shift-Enter"
],
"edit.openLineBelow": [
"Ctrl-Enter"
],
"edit.lineComment": [
"Ctrl-/"
],
Expand Down
2 changes: 2 additions & 0 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ define(function (require, exports, module) {
exports.EDIT_BLOCK_COMMENT = "edit.blockComment";
exports.EDIT_LINE_UP = "edit.lineUp";
exports.EDIT_LINE_DOWN = "edit.lineDown";
exports.EDIT_OPEN_LINE_ABOVE = "edit.openLineAbove";
exports.EDIT_OPEN_LINE_BELOW = "edit.openLineBelow";
exports.TOGGLE_CLOSE_BRACKETS = "edit.autoCloseBrackets";

// VIEW
Expand Down
91 changes: 75 additions & 16 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,63 @@ define(function (require, exports, module) {
moveLine(editor, DIRECTION_DOWN);
}

/**
* Inserts a new and smart indented line above/below the selected text, or current line if no selection.
* The cursor is moved in the new line.
* @param {Editor} editor - target editor
* @param {Number} direction - direction where to place the new line (-1,+1) => (Up,Down)
*/
function openLine(editor, direction) {
editor = editor || EditorManager.getFocusedEditor();
if (!editor) {
return;
}

var sel = editor.getSelection(),
hasSelection = (sel.start.line !== sel.end.line) || (sel.start.ch !== sel.end.ch),
cm = editor._codeMirror,
doc = editor.document,
line;

// Insert the new line
switch (direction) {
case DIRECTION_UP:
line = sel.start.line;
break;
case DIRECTION_DOWN:
line = sel.end.line;
if (!(hasSelection && sel.end.ch === 0)) {
// If not linewise selection
line++;
}
break;
}

doc.batchOperation(function () {
doc.replaceRange("\n", {line: line, ch: 0});
cm.indentLine(line);
});
editor.setSelection({line: line, ch: null});
}

/**
* Inserts a new and smart indented line above the selected text, or current line if no selection.
* The cursor is moved in the new line.
* @param {Editor} editor - target editor
*/
function openLineAbove(editor) {
openLine(editor, DIRECTION_UP);
}

/**
* Inserts a new and smart indented line below the selected text, or current line if no selection.
* The cursor is moved in the new line.
* @param {Editor} editor - target editor
*/
function openLineBelow(editor) {
openLine(editor, DIRECTION_DOWN);
}

/**
* Indent a line of text if no selection. Otherwise, indent all lines in selection.
*/
Expand Down Expand Up @@ -786,20 +843,22 @@ define(function (require, exports, module) {
}

// Register commands
CommandManager.register(Strings.CMD_INDENT, Commands.EDIT_INDENT, indentText);
CommandManager.register(Strings.CMD_UNINDENT, Commands.EDIT_UNINDENT, unidentText);
CommandManager.register(Strings.CMD_COMMENT, Commands.EDIT_LINE_COMMENT, lineComment);
CommandManager.register(Strings.CMD_BLOCK_COMMENT, Commands.EDIT_BLOCK_COMMENT, blockComment);
CommandManager.register(Strings.CMD_DUPLICATE, Commands.EDIT_DUPLICATE, duplicateText);
CommandManager.register(Strings.CMD_DELETE_LINES, Commands.EDIT_DELETE_LINES, deleteCurrentLines);
CommandManager.register(Strings.CMD_LINE_UP, Commands.EDIT_LINE_UP, moveLineUp);
CommandManager.register(Strings.CMD_LINE_DOWN, Commands.EDIT_LINE_DOWN, moveLineDown);
CommandManager.register(Strings.CMD_SELECT_LINE, Commands.EDIT_SELECT_LINE, selectLine);

CommandManager.register(Strings.CMD_UNDO, Commands.EDIT_UNDO, handleUndo);
CommandManager.register(Strings.CMD_REDO, Commands.EDIT_REDO, handleRedo);
CommandManager.register(Strings.CMD_CUT, Commands.EDIT_CUT, ignoreCommand);
CommandManager.register(Strings.CMD_COPY, Commands.EDIT_COPY, ignoreCommand);
CommandManager.register(Strings.CMD_PASTE, Commands.EDIT_PASTE, ignoreCommand);
CommandManager.register(Strings.CMD_SELECT_ALL, Commands.EDIT_SELECT_ALL, _handleSelectAll);
CommandManager.register(Strings.CMD_INDENT, Commands.EDIT_INDENT, indentText);
CommandManager.register(Strings.CMD_UNINDENT, Commands.EDIT_UNINDENT, unidentText);
CommandManager.register(Strings.CMD_COMMENT, Commands.EDIT_LINE_COMMENT, lineComment);
CommandManager.register(Strings.CMD_BLOCK_COMMENT, Commands.EDIT_BLOCK_COMMENT, blockComment);
CommandManager.register(Strings.CMD_DUPLICATE, Commands.EDIT_DUPLICATE, duplicateText);
CommandManager.register(Strings.CMD_DELETE_LINES, Commands.EDIT_DELETE_LINES, deleteCurrentLines);
CommandManager.register(Strings.CMD_LINE_UP, Commands.EDIT_LINE_UP, moveLineUp);
CommandManager.register(Strings.CMD_LINE_DOWN, Commands.EDIT_LINE_DOWN, moveLineDown);
CommandManager.register(Strings.CMD_OPEN_LINE_ABOVE, Commands.EDIT_OPEN_LINE_ABOVE, openLineAbove);
CommandManager.register(Strings.CMD_OPEN_LINE_BELOW, Commands.EDIT_OPEN_LINE_BELOW, openLineBelow);
CommandManager.register(Strings.CMD_SELECT_LINE, Commands.EDIT_SELECT_LINE, selectLine);

CommandManager.register(Strings.CMD_UNDO, Commands.EDIT_UNDO, handleUndo);
CommandManager.register(Strings.CMD_REDO, Commands.EDIT_REDO, handleRedo);
CommandManager.register(Strings.CMD_CUT, Commands.EDIT_CUT, ignoreCommand);
CommandManager.register(Strings.CMD_COPY, Commands.EDIT_COPY, ignoreCommand);
CommandManager.register(Strings.CMD_PASTE, Commands.EDIT_PASTE, ignoreCommand);
CommandManager.register(Strings.CMD_SELECT_ALL, Commands.EDIT_SELECT_ALL, _handleSelectAll);
});
2 changes: 2 additions & 0 deletions src/nls/it/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ define({
"CMD_BLOCK_COMMENT" : "Commenta/De-commenta blocco",
"CMD_LINE_UP" : "Sposta la riga in alto",
"CMD_LINE_DOWN" : "Sposta la riga in basso",
"CMD_OPEN_LINE_ABOVE" : "Apri linea in alto",
"CMD_OPEN_LINE_BELOW" : "Apri linea in basso",

// View menu commands
"VIEW_MENU" : "Vista",
Expand Down
2 changes: 2 additions & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,8 @@ define({
"CMD_BLOCK_COMMENT" : "Toggle Block Comment",
"CMD_LINE_UP" : "Move Line Up",
"CMD_LINE_DOWN" : "Move Line Down",
"CMD_OPEN_LINE_ABOVE" : "Open Line Above",
"CMD_OPEN_LINE_BELOW" : "Open Line Below",
"CMD_TOGGLE_CLOSE_BRACKETS" : "Auto Close Braces",

// View menu commands
Expand Down
Loading