-
Notifications
You must be signed in to change notification settings - Fork 373
Fix JS Programming decompiler: prevent space replacement with variable names #2541
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
Open
sensei-hacker
wants to merge
14
commits into
iNavFlight:maintenance-9.x
Choose a base branch
from
sensei-hacker:fix/js-programming-space-replacement-bug
base: maintenance-9.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a898009
Add LC-to-line mapping for active condition highlighting
sensei-hacker 744160f
Add Monaco integration for active LC highlighting
sensei-hacker 426e6ab
Add visual styling for active LC highlighting
sensei-hacker cb9ac21
Add null checks to prevent errors when FC data not loaded
sensei-hacker f999e71
Fix isDirty race condition preventing active LC highlighting
sensei-hacker 0a7c958
Track LC-to-line mappings during code generation
sensei-hacker d058d0f
Add debug logging to finalizeLcLineMapping
sensei-hacker 6d3e73d
Add debug logging to updateActiveHighlighting
sensei-hacker 1de1e9a
Fix critical bug: use getAll() instead of get() for LC status
sensei-hacker b12f9be
Improve active LC checkmark visibility with circle background and whi…
sensei-hacker 3590ef3
Add FALSE condition indicators and transpiler-side line tracking
sensei-hacker 10bdcd2
Address qodo-merge bot feedback and refactor highlighting logic
sensei-hacker a078606
Fix malformed JSDoc comment syntax
sensei-hacker ce1a193
Fix JS Programming decompiler replacing spaces with variable names
sensei-hacker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| /** | ||
| * Logic Condition Active Highlighting Module | ||
| * | ||
| * Provides visual feedback in the Monaco editor showing which Logic Conditions | ||
| * are currently TRUE (green checkmarks) or FALSE (gray circles). | ||
| */ | ||
|
|
||
| 'use strict'; | ||
|
|
||
| /** | ||
| * Categorize Logic Conditions by their current status (TRUE/FALSE) | ||
| * | ||
| * @param {Array<number>} lcStatus - Array of LC status values (0=FALSE, non-zero=TRUE) | ||
| * @param {Array<Object>} lcConditions - Array of LC condition objects | ||
| * @param {Object} lcToLineMapping - Map of LC index to editor line number | ||
| * @returns {Object} { trueLCs: number[], falseLCs: number[] } | ||
| */ | ||
| export function categorizeLCsByStatus(lcStatus, lcConditions, lcToLineMapping) { | ||
| const trueLCs = []; | ||
| const falseLCs = []; | ||
|
|
||
| for (let lcIndex = 0; lcIndex < lcStatus.length; lcIndex++) { | ||
| const status = lcStatus[lcIndex]; | ||
| const condition = lcConditions[lcIndex]; | ||
|
|
||
| // Only process enabled LCs that are in our mapping (i.e., visible in the editor) | ||
| if (condition && condition.getEnabled && condition.getEnabled() !== 0 && lcToLineMapping[lcIndex] !== undefined) { | ||
| if (status !== 0) { | ||
| trueLCs.push(lcIndex); | ||
| } else { | ||
| falseLCs.push(lcIndex); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return { trueLCs, falseLCs }; | ||
| } | ||
|
|
||
| /** | ||
| * Map LC indices to editor line numbers with their combined status | ||
| * | ||
| * Handles cases where multiple LCs map to the same line (shows "mixed" if both TRUE and FALSE exist) | ||
| * | ||
| * @param {number[]} trueLCs - Array of TRUE LC indices | ||
| * @param {number[]} falseLCs - Array of FALSE LC indices | ||
| * @param {Object} lcToLineMapping - Map of LC index to editor line number | ||
| * @returns {Object} Map of line number to status ('true'|'false'|'mixed') | ||
| */ | ||
| export function mapLCsToLines(trueLCs, falseLCs, lcToLineMapping) { | ||
| const lineStatus = {}; // { lineNum: 'true'|'false'|'mixed' } | ||
|
|
||
| // Process TRUE LCs | ||
| for (const lcIndex of trueLCs) { | ||
| const line = lcToLineMapping[lcIndex]; | ||
| if (line !== undefined) { | ||
| if (lineStatus[line] === 'false') { | ||
| lineStatus[line] = 'mixed'; // Both true and false LCs on same line | ||
| } else if (lineStatus[line] !== 'mixed') { | ||
| lineStatus[line] = 'true'; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Process FALSE LCs | ||
| for (const lcIndex of falseLCs) { | ||
| const line = lcToLineMapping[lcIndex]; | ||
| if (line !== undefined) { | ||
| if (lineStatus[line] === 'true') { | ||
| lineStatus[line] = 'mixed'; // Both true and false LCs on same line | ||
| } else if (lineStatus[line] !== 'mixed') { | ||
| lineStatus[line] = 'false'; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return lineStatus; | ||
| } | ||
|
|
||
| /** | ||
| * Create Monaco editor decorations from line status | ||
| * | ||
| * @param {Object} lineStatus - Map of line number to status ('true'|'false'|'mixed') | ||
| * @param {Object} monaco - Monaco editor instance (passed from caller) | ||
| * @returns {Array<Object>} Array of Monaco decoration objects | ||
| */ | ||
| export function createMonacoDecorations(lineStatus, monaco) { | ||
| return Object.entries(lineStatus).map(([lineNum, status]) => { | ||
| // For mixed status, show green checkmark (at least one condition is true) | ||
| const className = (status === 'true' || status === 'mixed') ? 'lc-active-true' : 'lc-active-false'; | ||
| const message = status === 'mixed' | ||
| ? 'Multiple logic conditions: at least one is TRUE' | ||
| : (status === 'true' ? 'Logic condition is TRUE' : 'Logic condition is FALSE'); | ||
|
|
||
| return { | ||
| range: new monaco.Range(parseInt(lineNum), 1, parseInt(lineNum), 1), | ||
| options: { | ||
| glyphMarginClassName: className, | ||
| glyphMarginHoverMessage: { | ||
| value: message | ||
| } | ||
| } | ||
| }; | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * Apply decorations to Monaco editor | ||
| * | ||
| * @param {Object} editor - Monaco editor instance | ||
| * @param {Array<Object>} currentDecorations - Current decoration IDs | ||
| * @param {Array<Object>} newDecorations - New decorations to apply | ||
| * @returns {Array<Object>} Updated decoration IDs | ||
| */ | ||
| export function applyDecorations(editor, currentDecorations, newDecorations) { | ||
| if (!editor || !editor.deltaDecorations) { | ||
| return currentDecorations || []; | ||
| } | ||
|
|
||
| return editor.deltaDecorations( | ||
| currentDecorations || [], | ||
| newDecorations | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Clear all decorations from Monaco editor | ||
| * | ||
| * @param {Object} editor - Monaco editor instance | ||
| * @param {Array<Object>} currentDecorations - Current decoration IDs to clear | ||
| * @returns {Array<Object>} Empty array (no decorations) | ||
| */ | ||
| export function clearDecorations(editor, currentDecorations) { | ||
| if (!editor || !editor.deltaDecorations || !currentDecorations) { | ||
| return []; | ||
| } | ||
|
|
||
| return editor.deltaDecorations(currentDecorations, []); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.