Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing the same query multiple times for Dev Tools #1174

Merged
merged 2 commits into from
Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions public/controllers/dev-tools/dev-tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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];
Expand Down Expand Up @@ -203,7 +223,7 @@ export class DevToolsController {
end
});
}

starts = [];
return tmpgroups;
} catch (error) {
return [];
Expand Down Expand Up @@ -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(
Expand Down