MXML: CTRL+Space Import in <fx:Script> block sometimes places import on very top of file
See original GitHub issueWhen 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
- 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>
- 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>
-
Use CTRL+Space to auto complete
-
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:
- Created 3 years ago
- Comments:12 (6 by maintainers)
Top GitHub Comments
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
@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.