Bug 818430 - Having line and token operators in the same query makes the scripts menulist behave weirdly, r=past

This commit is contained in:
Victor Porof 2012-12-11 09:38:04 +02:00
Родитель 2527dc3787
Коммит 6b34181b5c
2 изменённых файлов: 70 добавлений и 3 удалений

Просмотреть файл

@ -754,6 +754,7 @@ FilterView.prototype = {
if (!found) {
found = true;
view.selectedItem = item;
view.refresh();
}
}
// Item not matched, hide the corresponding node.
@ -778,9 +779,13 @@ FilterView.prototype = {
*/
_performLineSearch: function DVF__performLineSearch(aLine) {
// Don't search for lines if the input hasn't changed.
if (this._prevSearchedLine != aLine && aLine > 0) {
if (this._prevSearchedLine != aLine && aLine) {
DebuggerView.editor.setCaretPosition(aLine - 1);
}
// Can't search for lines and tokens at the same time.
if (this._prevSearchedToken && !aLine) {
this._target.refresh();
}
this._prevSearchedLine = aLine;
},
@ -793,13 +798,17 @@ FilterView.prototype = {
*/
_performTokenSearch: function DVF__performTokenSearch(aToken) {
// Don't search for tokens if the input hasn't changed.
if (this._prevSearchedToken != aToken && aToken.length > 0) {
if (this._prevSearchedToken != aToken && aToken) {
let editor = DebuggerView.editor;
let offset = editor.find(aToken, { ignoreCase: true });
if (offset > -1) {
editor.setSelection(offset, offset + aToken.length)
}
}
// Can't search for tokens and lines at the same time.
if (this._prevSearchedLine && !aToken) {
this._target.refresh();
}
this._prevSearchedToken = aToken;
},

Просмотреть файл

@ -50,6 +50,7 @@ function test()
}
function testScriptSearching() {
let noMatchingScripts = gDebugger.L10N.getStr("noMatchingScriptsText");
var token;
gDebugger.DebuggerController.activeThread.resume(function() {
@ -135,37 +136,87 @@ function testScriptSearching() {
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (6)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write(":13#" + token);
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (7)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write(":#" + token);
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (8)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("::#" + token);
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (9)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write(":::#" + token);
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (10)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("#" + token + ":bogus");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (6)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("#" + token + ":13");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (7)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("#" + token + ":");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (8)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("#" + token + "::");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (9)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("#" + token + ":::");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't jump to the correct token. (10)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write(":i am not a number");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't remain at the correct token. (11)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write("#__i do not exist__");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
"The editor didn't remain at the correct token. (12)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
token = "debugger";
@ -173,17 +224,23 @@ function testScriptSearching() {
ok(gEditor.getCaretPosition().line == 2 &&
gEditor.getCaretPosition().col == 44 + token.length,
"The editor didn't jump to the correct token. (12.1)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
clear();
EventUtils.sendKey("RETURN");
ok(gEditor.getCaretPosition().line == 2 &&
gEditor.getCaretPosition().col == 44 + token.length,
"The editor shouldn't jump to another token. (12.2)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
EventUtils.sendKey("ENTER");
ok(gEditor.getCaretPosition().line == 2 &&
gEditor.getCaretPosition().col == 44 + token.length,
"The editor shouldn't jump to another token. (12.3)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
write(":1:2:3:a:b:c:::12");
@ -196,7 +253,6 @@ function testScriptSearching() {
gEditor.getCaretPosition().col == 44 + token.length,
"The editor didn't jump to the correct token. (14)");
EventUtils.sendKey("DOWN");
ok(gEditor.getCaretPosition().line == 8 &&
gEditor.getCaretPosition().col == 2 + token.length,
@ -229,6 +285,8 @@ function testScriptSearching() {
"The editor didn't remain at the correct token. (19)");
is(gScripts.visibleItems, 1,
"Not all the scripts are shown after the search. (20)");
isnot(gMenulist.getAttribute("label"), noMatchingScripts,
"The menulist should not display a notice that matches are found.");
closeDebuggerAndFinish();
});