@@ -39768,6 +39768,9 @@ define("extensionsIntegrated/loader", function (require, exports, module) {
3976839768 * resolve({
3976939769 * originalText: "the original text sent to beautify",
3977039770 * changedText: "partial or full text that changed.",
39771+ * // Optional cursor offset if given will set the editor cursor to the position after beautification.
39772+ * // either `cursorOffset` or `ranges` can be specified, but not both.
39773+ * cursorOffset: number,
3977139774 * // Optional: If range is specified, only the given range will be replaced. else full text is replaced
3977239775 * ranges:{
3977339776 * replaceStart: {line,ch},
@@ -39785,6 +39788,8 @@ define("extensionsIntegrated/loader", function (require, exports, module) {
3978539788 * 1. `changedText` - string, this should be the fully prettified text of the whole `originalText` or a fragment of
3978639789 * pretty text in `originalText` if a range was selected. If a `fragment` is returned, then the
3978739790 * `ranges` object must be specified.
39791+ * 1. `cursorOffset` - Optional number, if given will set the editor cursor to the position after beautification.
39792+ * either `cursorOffset` or `ranges` can be specified, but not both.
3978839793 * 1. `ranges` - Optional object, set of 2 cursors that gives details on what range to replace with given changed text.
3978939794 * If range is not specified, the full text in the editor will be replaced. range has 2 fields:
3979039795 * 1. `replaceStart{line,ch}` - the start of range to replace
@@ -39897,10 +39902,11 @@ define("features/BeautificationManager", function (require, exports, module) {
3989739902 } else {
3989839903 let cursor = editor.getCursorPos();
3989939904 editor.replaceRange(beautyObject.changedText, ranges.replaceStart, ranges.replaceEnd);
39905+ if(beautyObject.cursorOffset || beautyObject.cursorOffset === 0){
39906+ // we have accurate cursor positioning from beautifier
39907+ cursor = editor.posFromIndex(beautyObject.cursorOffset);
39908+ }
3990039909 editor.setCursorPos(cursor.line, cursor.ch);
39901- // this cursor is not accurate. Trying to place this accurately is taking time,
39902- // tried diff parsing which worked, but parser taking lots of time to complete, diff parsing line wise
39903- // was giving better results but couldn't make it consistent.
3990439910 }
3990539911 }
3990639912 }
@@ -39942,7 +39948,7 @@ define("features/BeautificationManager", function (require, exports, module) {
3994239948 }
3994339949
3994439950 /**
39945- * Beautifies text in the given editor with available providers.
39951+ * Beautifies text with available providers.
3994639952 * @param {string} textToBeautify
3994739953 * @param {string} filePathOrFileName Note that the file path may not actually exist on disk. It is just used to
3994839954 * infer what language beautifier is to be applied.
@@ -40000,7 +40006,7 @@ define("features/BeautificationManager", function (require, exports, module) {
4000040006
4000140007 editor.displayErrorMessageAtCursor(message);
4000240008 ProjectManager.setProjectBusy(false, busyMessage);
40003- console.log ("No beautify providers responded", e);
40009+ console.warn ("No beautify providers responded", e);
4000440010 result.reject();
4000540011 });
4000640012 return result.promise();
@@ -149737,8 +149743,10 @@ define("widgets/infobar", function (require, exports, module) {
149737149743 */
149738149744
149739149745/*global Phoenix*/
149740- // @INCLUDE_IN_API_DOCS
149741149746/**
149747+ * This worker is for internal use inside PHCODE only. We do not want third party extensions breaking the core
149748+ * extensions.
149749+ *
149742149750 * This is a generic web worker that is available for use by extensions to offload extension related tasks. This
149743149751 * should only be used for performing small compute tasks and should not be used for long-running compute tasks.
149744149752 *
@@ -149785,7 +149793,10 @@ define("worker/ExtensionsWorker", function (require, exports, module) {
149785149793 WorkerComm = require("worker/WorkerComm");
149786149794
149787149795 const _ExtensionsWorker = new Worker(
149788- `${Phoenix.baseURL}worker/extensions-worker-thread.js?debug=${window.logger.logToConsolePref === 'true'}`);
149796+ `${Phoenix.baseURL}worker/extensions-worker-thread.js?debug=${window.logger.logToConsolePref === 'true'}`,
149797+ {
149798+ type: "module"
149799+ });
149789149800
149790149801 if(!_ExtensionsWorker){
149791149802 console.error("Could not load Extensions worker! Some extensions may not work as expected.");
@@ -150163,8 +150174,8 @@ define("worker/IndexingWorker", function (require, exports, module) {
150163150174 workerCommLoadCompleteInWorker = false;
150164150175 function loadPendingScripts() {
150165150176 workerCommLoadCompleteInWorker = true;
150166- for(let scriptUrl of loadScriptQueue){
150167- eventDispatcher.loadScriptInWorker(scriptUrl );
150177+ for(let queuedLoads of loadScriptQueue){
150178+ eventDispatcher.loadScriptInWorker(queuedLoads.scriptURL, queuedLoads.isModule );
150168150179 }
150169150180 loadScriptQueue = [];
150170150181 }
@@ -150178,20 +150189,27 @@ define("worker/IndexingWorker", function (require, exports, module) {
150178150189 * let ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
150179150190 * let addWorkerScriptPath = ExtensionUtils.getModulePath(module, "add_worker_Script.js")
150180150191 * await exports.loadScriptInWorker(addWorkerScriptPath);
150192+ * // if the worker is an es-module, then set optional isModule to true
150193+ * // Eg.loadScriptInWorker(addWorkerScriptPath, true);
150181150194 * @param {string} scriptURL the Full url to load.
150195+ * @param {boolean} isModule if the url is a module url
150182150196 * @type {function}
150183150197 */
150184- eventDispatcher.loadScriptInWorker = async function (scriptURL) {
150198+ eventDispatcher.loadScriptInWorker = async function (scriptURL, isModule ) {
150185150199 if(!workerCommLoadCompleteInWorker){
150186- loadScriptQueue.push(scriptURL);
150200+ loadScriptQueue.push({ scriptURL, isModule} );
150187150201 return;
150188150202 }
150189- await eventDispatcher.execPeer(EXEC_LOAD_SCRIPT, scriptURL);
150203+ await eventDispatcher.execPeer(EXEC_LOAD_SCRIPT, { scriptURL, isModule} );
150190150204 };
150191150205 } else {
150192- function _loadScriptHandler(url) {
150193- console.log(`${env}: loading script from url: ${url}`);
150194- importScripts(url);
150206+ function _loadScriptHandler({scriptURL, isModule}) {
150207+ console.log(`${env}: loading script from url: ${scriptURL}, isModule: ${isModule}`);
150208+ if(!isModule){
150209+ importScripts(scriptURL);
150210+ } else {
150211+ return import(scriptURL);
150212+ }
150195150213 }
150196150214 eventDispatcher.setExecHandler(EXEC_LOAD_SCRIPT, _loadScriptHandler);
150197150215 }
0 commit comments