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

Skip left most #396

Merged
merged 2 commits into from
Oct 31, 2024
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
9 changes: 6 additions & 3 deletions packages/core/src/editor/FreEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
RoleProvider
} from "./index.js";
import { FreError, FreErrorSeverity } from "../validator/index.js";
import { isExpressionPreOrPost, isNullOrUndefined } from "../util/index.js";
import { isExpressionPreOrPost, isNullOrUndefined, LEFT_MOST } from "../util/index.js";
import {FreErrorDecorator} from "./FreErrorDecorator.js";

const LOGGER = new FreLogger("FreEditor").mute();
Expand Down Expand Up @@ -292,9 +292,12 @@ export class FreEditor {
* Sets 'element' to be the selectedElement, and its first child, which is editable, to the selectedBox.
* @param element
*/
selectFirstEditableChildBox(element: FreNode) {
selectFirstEditableChildBox(element: FreNode, skip: boolean = false) {
if (this.checkParam(element)) {
const first = this.projection.getBox(element).firstEditableChild;
let first = this.projection.getBox(element).firstEditableChild;
if (skip && first.role === LEFT_MOST) {
first = first.nextLeafRight
}
if (!isNullOrUndefined(first)) {
this._selectedBox = first;
this._selectedProperty = first.propertyName;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/editor/actions/FreCreatePartCommand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class FreCreatePartCommand extends FreCommand {
" of kind " +
editor.selectedBox.kind,
);
editor.selectFirstEditableChildBox(newElement);
editor.selectFirstEditableChildBox(newElement, true);
};
}

Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/editor/util/FreExpressionUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@ export function createDefaultExpressionBox(exp: FreExpressionNode, children: Box
result = BoxFactory.horizontalLayout(exp, EXPRESSION, "", children);
}
if (isLeftMost) {
// TODO Change into Svelte Style
// result.insertChild(new ActionBox(exp, LEFT_MOST, NBSP, { style: STYLES.aliasExpression }));
result.insertChild(BoxFactory.action(exp, LEFT_MOST, NBSP));
}
if (isRightMost) {
// TODO Change into Svelte Style
// result.addChild(new ActionBox(exp, RIGHT_MOST, NBSP, { style: STYLES.aliasExpression }));
result.addChild(BoxFactory.action(exp, RIGHT_MOST, NBSP));
}
FreUtils.initializeObject(result, initializer);
Expand Down Expand Up @@ -96,10 +92,8 @@ export function createDefaultBinaryBox(
propertyName: "left",
conceptName: leftConceptName,
}),
// TODO Change into Svelte styles: style: STYLES.aliasExpression
BoxFactory.action(exp, BEFORE_BINARY_OPERATOR, NBSP),
createOperatorBox(editor, exp, symbol),
// TODO Change into Svelte styles: style: STYLES.aliasExpression
BoxFactory.action(exp, AFTER_BINARY_OPERATOR, NBSP),
!!exp.freRight()
? boxProviderCache.getBoxProvider(exp.freRight()).box
Expand Down