/// <summary> /// Attaches this instance to the given code editor. /// </summary> /// <param name="editor">Editor to attach to.</param> public bool Attach(IEmmetEditor editor) { _editor = editor; // Detect syntax at the caret position string contentType = editor.GetContentTypeInActiveBuffer(); if (string.IsNullOrEmpty(contentType)) return false; // css, less or scss if (contentType.EndsWith(@"ss")) { _syntax = contentType; } else if (contentType == @"htmlx" || contentType.StartsWith("razor")) { _syntax = @"html"; } else { this.TraceWarning($"Syntax {contentType} is not supported"); return false; } return true; }
/// <summary> /// Attaches this instance to the given code editor. /// </summary> /// <param name="editor">Editor to attach to.</param> public bool Attach(IEmmetEditor editor) { _editor = editor; // Detect syntax at the caret position string contentType = editor.GetContentTypeInActiveBuffer(); if (string.IsNullOrEmpty(contentType)) { return(false); } // css, less or scss if (contentType.EndsWith(@"ss")) { _syntax = contentType; } else if (contentType == @"htmlx" || contentType.StartsWith("razor")) { _syntax = @"html"; } else { this.TraceWarning($"Syntax {contentType} is not supported"); return(false); } return(true); }
public void RunCommand_ExpandsCssAbbreviation() { // Arrange string result = string.Empty; IEmmetEditor editor = Substitute.For <IEmmetEditor>(); editor.GetContentTypeInActiveBuffer().Returns("css"); editor.GetContent().Returns("p10"); editor.GetSelectionRange().Returns(new Range(3, 3)); editor.GetCurrentLineRange().Returns(new Range(0, 3)); editor.GetCaretPosition().Returns(3); editor.ReplaceContentRange(Arg.Do <string>(s => result = s), Arg.Any <int>(), Arg.Any <int>()); // Act _engine.RunCommand(PackageIds.CmdIDExpandAbbreviation, editor).Should().BeTrue(); result.Should().Be("padding: 10px;"); }