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

Ctrl-L to select line #2002

Merged
merged 7 commits into from
Nov 6, 2012
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
1 change: 1 addition & 0 deletions src/command/Commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ define(function (require, exports, module) {
exports.EDIT_COPY = "edit.copy";
exports.EDIT_PASTE = "edit.paste";
exports.EDIT_SELECT_ALL = "edit.selectAll";
exports.EDIT_SELECT_LINE = "edit.selectLine";
exports.EDIT_FIND = "edit.find";
exports.EDIT_FIND_IN_FILES = "edit.findInFiles";
exports.EDIT_FIND_NEXT = "edit.findNext";
Expand Down
2 changes: 2 additions & 0 deletions src/command/Menus.js
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,8 @@ define(function (require, exports, module) {
*/
menu = addMenu(Strings.EDIT_MENU, AppMenuBar.EDIT_MENU);
menu.addMenuItem(Commands.EDIT_SELECT_ALL, "Ctrl-A");
menu.addMenuItem(Commands.EDIT_SELECT_LINE, [{key: "Ctrl-L", platform: "win"},
{key: "Ctrl-L", platform: "mac"}]);
menu.addMenuDivider();
menu.addMenuItem(Commands.EDIT_FIND, "Ctrl-F");
menu.addMenuItem(Commands.EDIT_FIND_IN_FILES, "Ctrl-Shift-F");
Expand Down
14 changes: 11 additions & 3 deletions src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ define(function (require, exports, module) {
var Commands = require("command/Commands"),
Strings = require("strings"),
CommandManager = require("command/CommandManager"),
EditorManager = require("editor/EditorManager"),
Editor = require("editor/Editor").Editor;
EditorManager = require("editor/EditorManager");
Copy link
Member

Choose a reason for hiding this comment

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

Nice catch on the unneeded dependency

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks but that wasn't a catch. I just merged master into @deemeetar's old branch. Maybe the merge went wrong on my side, but the said dependency is indeed required by toggleUseTabChars(). Can you review that function and point me if it is valid, I will correct it otherwise.

Copy link
Member

Choose a reason for hiding this comment

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

Ah. Well luckily it turns out, toggleUseTabChars() was moved to a different module recently. So when you merge with master, that code will go away and the dependency on Editor will indeed no longer be needed.



/**
Expand Down Expand Up @@ -263,7 +262,15 @@ define(function (require, exports, module) {

editor._codeMirror.execCommand("indentLess");
}

function selectLine() {
var editor = EditorManager.getFocusedEditor();
if (editor) {
from = {line: editor.getSelection().start.line, ch: 0},
Copy link
Member

Choose a reason for hiding this comment

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

Missing var keyword, so this will crash when you run it (due to strict mode)

to = {line: editor.getSelection().end.line + 1, ch: 0};
editor.setSelection(from, to);
}
}

/**
* Toggles tabs/spaces preferences
*/
Expand All @@ -282,4 +289,5 @@ define(function (require, exports, module) {
CommandManager.register(Strings.CMD_LINE_DOWN, Commands.EDIT_LINE_DOWN, moveLineDown);
CommandManager.register(Strings.CMD_USE_TAB_CHARS, Commands.TOGGLE_USE_TAB_CHARS, toggleUseTabChars)
.setChecked(Editor.getUseTabChar());
CommandManager.register(Strings.CMD_SELECT_LINE), Commands.EDIT_SELECT_LINE, selectLine);
Copy link
Member

Choose a reason for hiding this comment

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

There's an extra ) on this line that causes a JS syntax error

});
1 change: 1 addition & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ define({
// Edit menu commands
"EDIT_MENU" : "Edit",
"CMD_SELECT_ALL" : "Select All",
"CMD_SELECT_ALL" : "Select Line",
Copy link
Member

Choose a reason for hiding this comment

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

Copy-paste error: the key should be "CMD_SELECT_LINE"

"CMD_FIND" : "Find",
"CMD_FIND_IN_FILES" : "Find in Files",
"CMD_FIND_NEXT" : "Find Next",
Expand Down