question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MXML: CTRL+Space Import in <fx:Script> block sometimes places import on very top of file

See original GitHub issue

When working within a Script block within an mxml file, CTRL+Space for completion/import sometimes places the import outside of the script block as the very first line of the file.

Steps to reproduce

  1. Create an mxml file with a Script block:
<?xml version="1.0" encoding="utf-8"?>
<j:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:j="library://ns.apache.org/royale/jewel"
    xmlns:js="library://ns.apache.org/royale/basic"
    xmlns:html="library://ns.apache.org/royale/html">

    <fx:Script>
        <![CDATA[
            
        ]]>
    </fx:Script>

</j:VGroup>
  1. Add some code that will allow auto complete
<?xml version="1.0" encoding="utf-8"?>
<j:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:j="library://ns.apache.org/royale/jewel"
    xmlns:js="library://ns.apache.org/royale/basic"
    xmlns:html="library://ns.apache.org/royale/html">

    <fx:Script>
        <![CDATA[
             private var test:RemoteOb
        ]]>
    </fx:Script>

</j:VGroup>
  1. Use CTRL+Space to auto complete

  2. Sometimes, the import will appear at the very top of the file

Expected Results

The import appears at the top of the Script block:

<?xml version="1.0" encoding="utf-8"?>
<j:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:j="library://ns.apache.org/royale/jewel"
    xmlns:js="library://ns.apache.org/royale/basic"
    xmlns:html="library://ns.apache.org/royale/html">

    <fx:Script>
        <![CDATA[
             import org.apache.royale.net.RemoteObject;

             private var test:RemoteObject;
        ]]>
    </fx:Script>

</j:VGroup>

Actual Results

import org.apache.royale.net.RemoteObject;

<?xml version="1.0" encoding="utf-8"?>
<j:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
    xmlns:j="library://ns.apache.org/royale/jewel"
    xmlns:js="library://ns.apache.org/royale/basic"
    xmlns:html="library://ns.apache.org/royale/html">

    <fx:Script>
        <![CDATA[
             private var test:RemoteObject;
        ]]>
    </fx:Script>

</j:VGroup>

Observations

I wish I had concrete steps on how to reproduce this issue; it is quite random/sporadic. I will add notes as I learn more.

It is possible that it may be tied to other features within VSCode like auto organize imports, or auto source formatting. I use Beautify for mxml, and ActionScript Tools for AS3. I have sometimes seen worse corruption after saving once this occurs as the imports are usually considerably off the viewable screen.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
joshtynjalacommented, Jul 16, 2021

If you’re interested in trying it out before I do the next release, feel free to try a nightly build.

https://github.com/BowlerHatLLC/vscode-as3mxml/wiki/Nightly-builds

1reaction
joshtynjalacommented, Jul 16, 2021

@brianraymes Thank you again! I can finally reproduce. It seems to happen when a missing import gets added automatically, but there were no existing imports in the <fx:Script> block beforehand.

Read more comments on GitHub >

github_iconTop Results From Across the Web

vim-ctrlspace/vim-ctrlspace: Vim Space Controller - GitHub
Welcome to the Vim-CtrlSpace plug-in for managing. your tabs, buffers, files,; workspaces (sessions),; bookmarks for your favorite projects.
Read more >
Vscode does not suggest imports when pressing CTRL + . but ...
I tried Ctrl + Space and selected UseCallback react which imports ... it all typed up - so for useState - type useSta...
Read more >
ArcGIS With Flex | PDF | Arc Gis | Esri - Scribd
ArcGIS With Flex - Free ebook download as PDF File (.pdf), Text File (.txt) or read book online for free. PDF version of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found