Skip to content
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions client/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const store = setupStore(initialState);

const DONATE_LOGO_IMAGE_URL = 'https://donorbox.org/images/white_logo.svg';

const showDonateCampaign = false;

if (
showDonateCampaign &&
window.location.href.indexOf('full') === -1 &&
window.location.href.indexOf('embed') === -1
) {
Expand Down
38 changes: 11 additions & 27 deletions client/utils/rename-variable.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {

const startIndex = node.start;
const endIndex = node.end;

if (node.name !== oldName) return;

const pos = cm.posFromIndex(startIndex);

if (
Expand All @@ -57,19 +54,15 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
parent.type === 'ArrowFunctionExpression') &&
parent.params.some((p) => p.type === 'Identifier' && p.name === oldName)
) {
if (!parent.params.includes(node)) {
return;
}
if (!parent.params.includes(node)) return;
}

if (
parent.type === 'MemberExpression' &&
parent.property === node &&
!parent.computed
) {
if (parent.object.type === 'ThisExpression' && !isBaseThis) {
return;
}
if (parent.object.type === 'ThisExpression' && !isBaseThis) return;
}

const thisContext = getContext(
Expand All @@ -84,6 +77,8 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
let shouldRenameGlobalVar = false;
const isThis = isThisReference(cm, ast, pos, oldName);

shouldRenameGlobalVar = isGlobal && thisContext === 'global';

// Handle renaming inside classes
if (isInsideClassContext) {
const tempPos = {
Expand Down Expand Up @@ -121,14 +116,6 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
isThis === isBaseThis &&
baseContext === thisContext
) {
Object.entries(classMeta.methodVars || {}).forEach(
([methodName, vars]) => {
if (!vars.includes(oldName) && thisContext === methodName) {
const shouldRenameMethodVar = true;
}
}
);

shouldRename =
thisContext === baseContext &&
(currentMethodName === 'constructor' || shouldRenameGlobalVar);
Expand Down Expand Up @@ -162,7 +149,6 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
isGlobal &&
!Object.prototype.hasOwnProperty.call(thisScopeVars, oldName);
}
shouldRenameGlobalVar = isGlobal && thisContext === 'global';
}
// Handle renaming outside classes
else {
Expand Down Expand Up @@ -201,15 +187,13 @@ function startRenaming(cm, ast, fromPos, newName, oldName) {
isBaseThis
);

if (
isThisGlobal &&
thisContext in userDefinedFunctionMetadata &&
userDefinedFunctionMetadata[thisContext].params.some(
(param) => param.p === oldName
)
) {
return;
}
const params = userDefinedFunctionMetadata[thisContext]?.params || [];
const hasParamNamedOldName = params.some((param) =>
typeof param === 'string'
? param === oldName
: param?.name === oldName || param?.p === oldName
);
if (isThisGlobal && hasParamNamedOldName) return;

const methodPath = path.findParent((p) => p.isClassMethod());
let currentMethodName = null;
Expand Down
2 changes: 1 addition & 1 deletion client/utils/showRenameDialog.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import announceToScreenReader from './ScreenReaderHelper';
import p5CodeAstAnalyzer from './p5CodeAstAnalyzer';
import { getClassContext, getContext, getAST } from './renameVariableHelper';
import { getContext, getAST } from './renameVariableHelper';

const allFuncs = require('./p5-reference-functions.json');

Expand Down
2 changes: 1 addition & 1 deletion common/p5Versions.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const currentP5Version = '1.11.10'; // Don't update to 2.x until 2026
export const currentP5Version = '1.11.11'; // Don't update to 2.x until 2026

// Generated from https://www.npmjs.com/package/p5?activeTab=versions
// Run this in the console:
Expand Down
Loading