From d85ddb4f4c41f4e0ccb376c6e33d1798e37dfe88 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Tue, 11 Mar 2014 20:55:13 +0100 Subject: [PATCH] Sense: Move to first request upon open Closes #134 --- sense/app/app.js | 3 ++- sense/app/sense_editor/editor.js | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sense/app/app.js b/sense/app/app.js index 80da6896d8633..c31686dc7ddb9 100644 --- a/sense/app/app.js +++ b/sense/app/app.js @@ -129,6 +129,7 @@ define([ } $.ajax(loadFrom).done(function (data) { resetToValues(defaultHost, data); + input.moveToNextRequestEdge(true); input.highlightCurrentRequestAndUpdateActionBar(); input.updateActionsBar(); }); @@ -139,7 +140,7 @@ define([ else { resetToValues(defaultHost); } - + input.moveToNextRequestEdge(true); }()); (function setupAutosave() { diff --git a/sense/app/sense_editor/editor.js b/sense/app/sense_editor/editor.js index 5a7ea433e38b2..c3a40f477f0d2 100644 --- a/sense/app/sense_editor/editor.js +++ b/sense/app/sense_editor/editor.js @@ -252,10 +252,13 @@ define([ editor.moveCursorTo(pos.row, 0); }); - editor.moveToNextRequestEdge = onceDoneTokenizing(function () { + editor.moveToNextRequestEdge = onceDoneTokenizing(function (moveOnlyIfNotOnEdge) { var pos = editor.getCursorPosition(); var maxRow = editor.getSession().getLength(); - for (pos.row++; pos.row < maxRow && !editor.parser.isRequestEdge(pos.row); pos.row++) { + if (!moveOnlyIfNotOnEdge) { + pos.row++; + } + for (; pos.row < maxRow && !editor.parser.isRequestEdge(pos.row); pos.row++) { } editor.moveCursorTo(pos.row, 0); });