diff --git a/browser/devtools/debugger/debugger-view.js b/browser/devtools/debugger/debugger-view.js index 758cb054001..6409388c009 100644 --- a/browser/devtools/debugger/debugger-view.js +++ b/browser/devtools/debugger/debugger-view.js @@ -461,7 +461,7 @@ ScriptsView.prototype = { if (line > -1) { editor.setCaretPosition(line - 1); } - if (token) { + if (token.length) { let offset = editor.find(token, { ignoreCase: true }); if (offset > -1) { editor.setSelection(offset, offset + token.length) @@ -480,6 +480,10 @@ ScriptsView.prototype = { if (e.keyCode === e.DOM_VK_RETURN || e.keyCode === e.DOM_VK_ENTER) { let token = this._getSearchboxInfo()[2]; + if (!token.length) { + return; + } + let editor = DebuggerView.editor; let offset = editor.findNext(true); if (offset > -1) { diff --git a/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js b/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js index 077c547bc70..31e90d5bb46 100644 --- a/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js +++ b/browser/devtools/debugger/test/browser_dbg_scripts-searching-01.js @@ -124,6 +124,23 @@ function testScriptSearching() { token = "debugger"; + write("#" + token); + ok(gEditor.getCaretPosition().line == 2 && + gEditor.getCaretPosition().col == 44 + token.length, + "The editor didn't jump to the correct token. (12.1)"); + + 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)"); + + EventUtils.sendKey("ENTER"); + ok(gEditor.getCaretPosition().line == 2 && + gEditor.getCaretPosition().col == 44 + token.length, + "The editor shouldn't jump to another token. (12.3)"); + + write(":1:2:3:a:b:c:::12"); ok(gEditor.getCaretPosition().line == 11 && gEditor.getCaretPosition().col == 0,