Bug 919707 - Make shift-click on a gutter select whole lines in the editor. r=robcee

This commit is contained in:
Anton Kovalyov 2013-11-26 14:32:28 -08:00
parent 64cc922f74
commit 6258579c2a
2 changed files with 18 additions and 1 deletions

View File

@ -238,9 +238,19 @@ Editor.prototype = {
cm.on("focus", () => this.emit("focus"));
cm.on("change", () => this.emit("change"));
cm.on("gutterClick", (cm, line) => this.emit("gutterClick", line));
cm.on("cursorActivity", (cm) => this.emit("cursorActivity"));
cm.on("gutterClick", (cm, line, gutter, ev) => {
let head = { line: line, ch: 0 };
let tail = { line: line, ch: this.getText(line).length };
// Shift-click on a gutter selects the whole line.
if (ev.shiftKey)
return void cm.setSelection(head, tail);
this.emit("gutterClick", line);
});
win.CodeMirror.defineExtension("l10n", (name) => {
return L10N.GetStringFromName(name);
});

View File

@ -31,6 +31,13 @@ function test() {
ed.dropSelection();
is(ed.getSelection(), "", "dropSelection");
// Check that shift-click on a gutter selects the whole line (bug 919707)
let iframe = win.document.querySelector("iframe");
let gutter = iframe.contentWindow.document.querySelector(".CodeMirror-gutters");
EventUtils.sendMouseEvent({ type: "mousedown", shiftKey: true }, gutter, iframe.contentWindow);
is(ed.getSelection(), "Hello.", "shift-click");
teardown(ed, win);
});
}