/// <summary>
        /// JavaScript callback. Returns current line's start and end indexes as object with
        /// <code>start</code> and <code>end</code> properties.
        /// </summary>
        public InternalHandle GetCurrentLineRange(
            V8Engine engine,
            bool isConstructCall,
            InternalHandle self,
            params InternalHandle[] args)
        {
            var line = _editor.GetCurrentLineRange();

            ObjectHandle retVal = engine.CreateObject();

            retVal.SetProperty("start", engine.CreateValue(line.Start));
            retVal.SetProperty("end", engine.CreateValue(line.End));

            return(retVal);
        }
Example #2
0
        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;");
        }