Bug 911916 - Search set to identifier under cursor if no text selected. r=vp

This commit is contained in:
Mahdi Dibaiee 2014-01-23 09:39:59 -05:00
parent b072bd765c
commit f915adbfe8
3 changed files with 47 additions and 1 deletions

View File

@ -1068,7 +1068,24 @@ FilterView.prototype = {
_doSearch: function(aOperator = "", aText = "") {
this._searchbox.focus();
this._searchbox.value = ""; // Need to clear value beforehand. Bug 779738.
this._searchbox.value = aOperator + (aText || DebuggerView.editor.getSelection());
if (aText) {
this._searchbox.value = aOperator + aText;
}
else if (DebuggerView.editor.somethingSelected()) {
this._searchbox.value = aOperator + DebuggerView.editor.getSelection();
}
else {
let cursor = DebuggerView.editor.getCursor();
let content = DebuggerView.editor.getText();
let location = DebuggerView.Sources.selectedValue;
let source = DebuggerController.Parser.get(content, location);
let identifier = source.getIdentifierAt({ line: cursor.line+1, column: cursor.ch });
if (identifier && identifier.name) {
this._searchbox.value = aOperator + identifier.name;
}
}
},
/**

View File

@ -247,6 +247,7 @@ support-files =
[browser_dbg_variables-view-webidl.js]
[browser_dbg_watch-expressions-01.js]
[browser_dbg_watch-expressions-02.js]
[browser_dbg_search-function.js]
[browser_dbg_chrome-create.js]
skip-if = os == "linux" # Bug 847558
[browser_dbg_on-pause-raise.js]

View File

@ -0,0 +1,28 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Tests that Debugger Search uses the identifier under cursor
* if nothing is selected or manually passed
*/
"use strict";
function test() {
const TAB_URL = EXAMPLE_URL + "doc_function-search.html";
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
let Source = 'code_function-search-01.js';
let Debugger = aPanel.panelWin;
let Editor = Debugger.DebuggerView.editor;
let Filtering = Debugger.DebuggerView.Filtering;
waitForSourceShown(aPanel, Source).then(() => {
Editor.setCursor({ line: 7, ch: 0});
Filtering._doSearch("@");
is(Filtering._searchbox.value, "@test", "Searchbox value should be set to the identifier under cursor if no aText or selection provided");
closeDebuggerAndFinish(aPanel);
});
});
};