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

Code Editor 2: "Auto-indent clipboard content" inserts tabs where they don't belong #6708

Closed
1 of 2 tasks
DragoniteSpam opened this issue Jul 16, 2024 · 8 comments
Closed
1 of 2 tasks
Assignees
Labels
ide-bug Bugs with the GameMaker IDE
Milestone

Comments

@DragoniteSpam
Copy link

Description

I'm not sure if this is the same bug as #5356 or not, which looks like it has to do with curly brace behavior

When you paste code into an area with the same indentation level as the place where it came from, extra tabs get added

ce2 auto indent

This doesn't happen if the Auto Indent setting is turned off

Expected Change

No response

Steps To Reproduce

  1. Start GameMaker
  2. See the issue

How reliably can you recreate this issue using your steps above?

Always

Which version of GameMaker are you reporting this issue for?

2024.600 (Betas)

Which operating system(s) are you seeing the problem on?

Windows 10

Are you running GameMaker from inside your Steam library?

No

Contact Us Package Attached?

  • I have attached my Contact Us Package

Sample Project Added?

  • I have included a small sample project
@DragoniteSpam DragoniteSpam added the ide-bug Bugs with the GameMaker IDE label Jul 16, 2024
@DragoniteSpam
Copy link
Author

DragoniteSpam commented Jul 16, 2024

Tabs also behave badly if you paste single strings mid-line. This is probably the same bug but it might not be.

ce2 auto indent in line

Once again, it doesn't do this if the Auto Indent setting is turned off.

edit: I misspelled "snowman" didn't I

@stuckie stuckie moved this from Triage to Todo in Team Workload Jul 17, 2024
@stuckie stuckie modified the milestones: 2024.8, 2024.10 Jul 17, 2024
@zreedy
Copy link

zreedy commented Aug 30, 2024

Fixed. See #6243 for details

@zreedy zreedy moved this from Todo to In Progress in Team Workload Aug 30, 2024
@zreedy zreedy closed this as completed Sep 2, 2024
@github-project-automation github-project-automation bot moved this from In Progress to Done in Team Workload Sep 2, 2024
@gurpreetsinghmatharoo gurpreetsinghmatharoo moved this from Done to Ready for QA in Team Workload Sep 3, 2024
@YYDan YYDan changed the title CE2: Auto-indent clipboard content inserts tabs where they don't belong Code Editor 2: Auto-indent clipboard content inserts tabs where they don't belong Sep 19, 2024
@YYDan YYDan changed the title Code Editor 2: Auto-indent clipboard content inserts tabs where they don't belong Code Editor 2: "Auto-indent clipboard content" inserts tabs where they don't belong Sep 19, 2024
@caitlinrmcintyre
Copy link

Reopening as I'm still seeing a similar issue in IDE v2024.1100.0.624 Runtime v2024.1100.0.650, thanks.

@github-project-automation github-project-automation bot moved this from Ready for QA to Triage in Team Workload Sep 23, 2024
@stuckie stuckie moved this from Triage to Todo in Team Workload Sep 24, 2024
@caitlinrmcintyre
Copy link

caitlinrmcintyre commented Sep 26, 2024

Following the same steps as reported, this was the result I got.
Screenshot 2024-09-26 155050

Here's the code to repro:

static GetRelevantSprite = function(direction) {
    // prioritize the up/down directions
    if (direction < 45 || direction > 315) return self.sprite_right; 
    if (direction <= 135) return self.sprite_up;
    if (direction < 225) return self.sprite_up;
    return self.sprite_down;
};

@zreedy zreedy moved this from Todo to In Progress in Team Workload Oct 24, 2024
@zreedy
Copy link

zreedy commented Oct 25, 2024

I'm not sure this issue is fully resolvable without a full fat pretty printer. The current heuristic is that the clipboard contents are reformatted to the local indentation level by calculating the indent delta from the first line of the clipboard contents and the insertion line. This works well if the clipboard contents are fully qualified (i.e. the leading whitespace is preserved on all lines). However, if the first line's whitespace is missing and subsequent lines preserve their indentation there is no way to recover the missing indentation for the delta calculation. Any assumption you make will inevitably be wrong in some context.

The only solution is to completely dismiss any indentation in the clipboard contents and run them through a pretty printer in context of the insertion line. This is what the old implementation did, however the old implementation relied on our single-line indentation pretty printer which is not a full fat pretty printer and is incapable of calculating indentation appropriately for all styles that users might want (or even correct indentation for BSD-style in some cases).

The only solution I can see for now is to simply disable this feature until a full fat pretty printer is developed.

For documentation purposes I have attempted the following alternative heuristics to no success in all contexts.
Contexts (based on the above code, starting from just that code):

  1. Insert new line on line 1 + Paste lines [2, 5] on line 1
  2. Insert new line on line 7 + Paste lines [1, 7] on line 8
  3. Insert new line on line 6 + Insert 1 tab on line 7 + Paste lines [2, 5] on line 7

Heuristics (IL is Resolve Indentation Level for string, TS is Resolve Terminal Tab Stop via in-context single-line pretty printer):

  • newTabStop = IL(docLines[insertLine]), oldTabStop = IL(clipboardLines[0])
    • oldTabStop = IL(clipboardLines[0]) or if 0 then max(0, TS(docLines[insertLine]))
    • oldTabStop = IL(clipboardLines[0]) or if 0 then max(0, TS(docLines[insertLine + 1]))
    • oldTabStop = IL(clipboardLines[0]) or if 0 then max(0, TS(docLines[insertLine + 1]) - TS(docLines[insertLine]))
  • tabDeltaExt calculated per line > 0 given TS(docLines[insertLine + i]) after insertion in context -> tabDelta - tabDeltaExt
  • indent = GEN(IL(docLines[i]) + TS(clipboardLines[i]) + tabDelta)
  • indent = GEN(IL(docLines[i]) + TS(clipboardLines[i]) + tabDelta - tabDeltaExt)
  • All heuristics from group 1 with greedy preservation of existing indentation (best case coverage)

None of these have successfully handled all 3 contexts.

@gnysek
Copy link
Contributor

gnysek commented Oct 28, 2024

Until there's no pretty printer, same results as CE1 (if it's possible) would be enough. We're used for years to how it works, so would be good if there's no change here.

@stuckie stuckie modified the milestones: 2024.11, 2025.1 Nov 12, 2024
@zreedy zreedy moved this from In Progress to Backlog in Team Workload Nov 19, 2024
@zreedy zreedy moved this from Backlog to Todo in Team Workload Nov 21, 2024
@zreedy
Copy link

zreedy commented Nov 29, 2024

This feature has temporarily been removed due to the above stated reasons.

@alicemoretti
Copy link
Contributor

Verified on IDE v9.9.1.900 Runtime v9.9.1.1044.
The option to "Auto indent clipboard content" has been removed.
Thank you.

@alicemoretti alicemoretti moved this from Ready for QA to Verified in Team Workload Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ide-bug Bugs with the GameMaker IDE
Projects
Status: Verified
Development

No branches or pull requests

6 participants