Merge pull request #1174 from wazuh/issue-1172

Allowing the same query multiple times for Dev Tools
This commit is contained in:
Jesús Ángel 2019-01-23 14:56:22 +01:00 committed by GitHub
commit a09147ee7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -153,7 +153,7 @@ export class DevToolsController {
let start = 0;
let end = 0;
let starts = [];
const slen = splitted.length;
for (let i = 0; i < slen; i++) {
let tmp = splitted[i].split('\n');
@ -165,6 +165,26 @@ export class DevToolsController {
if (cursor.findNext()) start = cursor.from().line;
else return [];
/**
* Prevents from user frustation when there are duplicated queries.
* We want to look for the next query when available, even if it
* already exists but it's not the selected query.
*/
if (tmp.length) {
// It's a safe loop since findNext method returns null if there is no next query.
while (
this.apiInputBox.getLine(cursor.from().line) !== tmp[0] &&
cursor.findNext()
) {
start = cursor.from().line;
}
// It's a safe loop since findNext method returns null if there is no next query.
while (starts.includes(start) && cursor.findNext()) {
start = cursor.from().line;
}
}
starts.push(start);
end = start + tmp.length;
const tmpRequestText = tmp[0];
@ -203,7 +223,7 @@ export class DevToolsController {
end
});
}
starts = [];
return tmpgroups;
} catch (error) {
return [];
@ -433,7 +453,6 @@ export class DevToolsController {
calculateWhichGroup(firstTime) {
try {
const selection = this.apiInputBox.getCursor();
const desiredGroup = firstTime
? this.groups.filter(item => item.requestText)
: this.groups.filter(