/// <summary> /// JavaScript callback. Returns character indexes of selected text: object with <code>start</code> /// and <code>end</code> properties.If there's no selection, should return object with /// <code>start</code> and <code>end</code> properties referring to current caret position. /// </summary> public InternalHandle GetSelectionRange( V8Engine engine, bool isConstructCall, InternalHandle self, params InternalHandle[] args) { var selection = _editor.GetSelectionRange(); ObjectHandle retVal = engine.CreateObject(); retVal.SetProperty("start", engine.CreateValue(selection.Start)); retVal.SetProperty("end", engine.CreateValue(selection.End)); return(retVal); }
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;"); }