Skip to content
15 changes: 10 additions & 5 deletions src/extensions/default/DebugCommands/MacroRunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,10 +498,12 @@ define(function (require, exports, module) {
/**
* Opens a file in the first pane (left/top)
* @param {string} filePath - Project relative or absolute file path
* @param {boolean} [addToWorkingSet] - true to add to working set
* @returns {Promise} A promise that resolves when the file is opened
*/
openFileInFirstPane: function(filePath) {
return jsPromise(CommandManager.execute(Commands.FILE_OPEN, {
openFileInFirstPane: function(filePath, addToWorkingSet) {
const command = addToWorkingSet ? Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN : Commands.FILE_OPEN;
return jsPromise(CommandManager.execute(command, {
fullPath: _getFullPath(filePath),
paneId: "first-pane"
}));
Expand All @@ -510,10 +512,12 @@ define(function (require, exports, module) {
/**
* Opens a file in the second pane (right/bottom)
* @param {string} filePath - Project relative or absolute file path
* @param {boolean} addToWorkingSet - true to add to working set
* @returns {Promise} A promise that resolves when the file is opened
*/
openFileInSecondPane: function(filePath) {
return jsPromise(CommandManager.execute(Commands.FILE_OPEN, {
openFileInSecondPane: function(filePath, addToWorkingSet) {
const command = addToWorkingSet ? Commands.CMD_ADD_TO_WORKINGSET_AND_OPEN : Commands.FILE_OPEN;
return jsPromise(CommandManager.execute(command, {
fullPath: _getFullPath(filePath),
paneId: "second-pane"
}));
Expand Down Expand Up @@ -772,7 +776,8 @@ define(function (require, exports, module) {
closeFile, closeAll, undo, redo, setPreference, getPreference, validateEqual, validateNotEqual, execCommand,
saveActiveFile,
awaitsFor, waitForModalDialog, waitForModalDialogClosed, clickDialogButtonID, clickDialogButton,
EDITING, $, Commands, Dialogs
EDITING, // contains apis like splitVertical, openFileInFirstPane. focus pane etc...
$, Commands, Dialogs
};

async function runMacro(macroText) {
Expand Down
30 changes: 16 additions & 14 deletions src/search/FindReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ define(function (require, exports, module) {
}

/** Removes the current-match highlight, leaving all matches marked in the generic highlight style */
function clearCurrentMatchHighlight(cm, state) {
function clearCurrentMatchHighlight(editor, state) {
if (state.markedCurrent) {
state.markedCurrent.clear();
ScrollTrackMarkers.markCurrent(-1);
ScrollTrackMarkers.markCurrent(-1, editor);
}
}

Expand All @@ -405,7 +405,7 @@ define(function (require, exports, module) {
const pos = editor.getCursorPos(false, "start");
cm.operation(function () {
var state = getSearchState(cm);
clearCurrentMatchHighlight(cm, state);
clearCurrentMatchHighlight(editor, state);

let curIndex = editor.indexFromPos(pos);
curIndex = curIndex >= 1 ? curIndex-- : 0;
Expand All @@ -424,7 +424,7 @@ define(function (require, exports, module) {
{from: thisMatch.start, to: thisMatch.end}, false);
// Update current-tickmark indicator - only if highlighting enabled (disabled if FIND_HIGHLIGHT_MAX threshold hit)
if (state.marked.length) {
ScrollTrackMarkers.markCurrent(state.matchIndex); // _updateFindBarWithMatchInfo() has updated this index
ScrollTrackMarkers.markCurrent(state.matchIndex, editor); // _updateFindBarWithMatchInfo() has updated this index
}
}

Expand Down Expand Up @@ -454,7 +454,7 @@ define(function (require, exports, module) {
var cm = editor._codeMirror;
cm.operation(function () {
var state = getSearchState(cm);
clearCurrentMatchHighlight(cm, state);
clearCurrentMatchHighlight(editor, state);

var nextMatch = _getNextMatch(editor, searchBackwards, pos);
if (nextMatch) {
Expand All @@ -464,7 +464,7 @@ define(function (require, exports, module) {
{from: nextMatch.start, to: nextMatch.end}, searchBackwards);
// Update current-tickmark indicator - only if highlighting enabled (disabled if FIND_HIGHLIGHT_MAX threshold hit)
if (state.marked.length) {
ScrollTrackMarkers.markCurrent(state.matchIndex); // _updateFindBarWithMatchInfo() has updated this index
ScrollTrackMarkers.markCurrent(state.matchIndex, editor); // _updateFindBarWithMatchInfo() has updated this index
}
}

Expand All @@ -485,31 +485,33 @@ define(function (require, exports, module) {
}

/** Clears all match highlights, including the current match */
function clearHighlights(cm, state) {
function clearHighlights(editor, state) {
const cm = editor._codeMirror;
cm.operation(function () {
state.marked.forEach(function (markedRange) {
markedRange.clear();
});
clearCurrentMatchHighlight(cm, state);
clearCurrentMatchHighlight(editor, state);
});
state.marked.length = 0;
state.markedCurrent = null;

ScrollTrackMarkers.clear();
ScrollTrackMarkers.clear(editor);

state.resultSet = [];
state.matchIndex = -1;
}

function clearSearch(cm) {
function clearSearch(editor) {
const cm = editor._codeMirror;
cm.operation(function () {
var state = getSearchState(cm);
if (!state.parsedQuery) {
return;
}
setQueryInfo(state, null);

clearHighlights(cm, state);
clearHighlights(editor, state);
});
}

Expand Down Expand Up @@ -544,7 +546,7 @@ define(function (require, exports, module) {
cm.operation(function () {
// Clear old highlights
if (state.marked) {
clearHighlights(cm, state);
clearHighlights(editor, state);
}

if (!state.parsedQuery) {
Expand Down Expand Up @@ -676,7 +678,7 @@ define(function (require, exports, module) {
.on("close.FindReplace", function (e) {
editor.lastParsedQuery = state.parsedQuery;
// Clear highlights but leave search state in place so Find Next/Previous work after closing
clearHighlights(cm, state);
clearHighlights(editor, state);

// Dispose highlighting UI (important to restore normal selection color as soon as focus goes back to the editor)
toggleHighlighting(editor, false);
Expand Down Expand Up @@ -770,7 +772,7 @@ define(function (require, exports, module) {

if (editor) {
// Create a new instance of the search bar UI
clearSearch(editor._codeMirror);
clearSearch(editor);
doSearch(editor, false);
}
}
Expand Down
Loading
Loading