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

case "string": snippet completion #337

Closed
Yanrishatum opened this issue Apr 21, 2019 · 3 comments
Closed

case "string": snippet completion #337

Yanrishatum opened this issue Apr 21, 2019 · 3 comments

Comments

@Yanrishatum
Copy link

When entering : after doing a case on String value, it triggers completion with snippets in some cases, and pressing enter causes the snippet to execute instead of adding a new line.
Code sample:

	function buildWidths( e : Xml, state : TextState, nodes : Array<HtmlNode>, widths : Array<Float> ) {
		if ( e.nodeType == Xml.Element ) {
			inline function makeLineBreak() {
				var fontInfo = lineHeightMode == Constant ? this.font : state.font;
				widths.push(0);
				nodes.push(LineBreak(state.align));
				newLine = true;
				prevChar = -1;
				lastBreak.clear();
			}
			var nodeName = e.nodeName.toLowerCase();
			switch ( nodeName ) {
				case "p":
					for ( a in e.attributes() ) {
						switch ( a ) {
							case "align":
								switch ( e.get(a) ) {
									case "left": state.align = Left;
									case "right": state.align = Right;
									case "center": state.align = Center;
									case "multiline-center": state.align = MultilineCenter;
									case "multiline-right": state.align = MultilineRight;
								}
						}
					}
					if ( !newLine ) 
						makeLineBreak();
					else {
						nodes[nodes.length - 1] = LineBreak(state.align);
					}
				case "br":
					makeLineBreak();
				case "img":
					// TODO
				case "font":
					for ( a in e.attributes() ) {
						switch( a.toLowerCase() ) {
							case "face":
								state.font = loadFont(e.get(a));
							case "color":
								var v = e.get(a);
								if ( v.charCodeAt(0) == '#'.code && v.length == 4)
									v = "#" + v.charAt(1) + v.charAt(1) + v.charAt(2) + v.charAt(2) + v.charAt(3) + v.charAt(3);
								state.color = Std.parseInt("0x" + v.substr(1));
							case "opacity":| <----
							default:
						}
					}
				default:
			}
		}
	}

Pressing enter after case "opacity": causes entire case "font": to be included in snippet var name = case "font":

@Gama11
Copy link
Member

Gama11 commented Apr 21, 2019

This seems like a pretty important regression (at least I doubt this was happening before). Thanks for reporting!

@Gama11
Copy link
Member

Gama11 commented Apr 21, 2019

Seems to be caused by a Haxe bug (HaxeFoundation/haxe#8194), but should be able to work around it on the language server side.

A possible workaround for now is to turn postfix completion off:

"haxe.postfixCompletion": {
	"level": "off"
}

@Gama11
Copy link
Member

Gama11 commented Apr 21, 2019

Fix released in 2.9.1.

Gama11 added a commit to vshaxe/haxe-language-server that referenced this issue Jun 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants