Example #1
0
        public virtual void Dispose()
        {
            if (_vimErrorDetector.HasErrors())
            {
                var msg = String.Format("Extension Exception: {0}", _vimErrorDetector.GetErrors().First().Message);
                throw new Exception(msg);
            }
            _vimErrorDetector.Clear();

            _vim.VimData.SearchHistory.Clear();
            _vim.VimData.CommandHistory.Clear();
            _vim.VimData.LastCommand      = FSharpOption <StoredCommand> .None;
            _vim.VimData.LastShellCommand = FSharpOption <string> .None;

            _vim.KeyMap.ClearAll();
            _vim.MarkMap.ClearGlobalMarks();
            _vim.CloseAllVimBuffers();

            // Reset all of the global settings back to their default values.   Adds quite
            // a bit of sanity to the test bed
            foreach (var setting in _vim.GlobalSettings.AllSettings)
            {
                if (!setting.IsValueDefault && !setting.IsValueCalculated)
                {
                    _vim.GlobalSettings.TrySetValue(setting.Name, setting.DefaultValue);
                }
            }

            // Reset all of the register values to empty
            foreach (var name in _vim.RegisterMap.RegisterNames)
            {
                _vim.RegisterMap.GetRegister(name).UpdateValue("");
            }

            // Don't let recording persist across tests
            if (_vim.MacroRecorder.IsRecording)
            {
                _vim.MacroRecorder.StopRecording();
            }

            var vimHost = Vim.VimHost as MockVimHost;

            if (vimHost != null)
            {
                vimHost.Clear();
            }

            VariableMap.Clear();
        }
Example #2
0
 public void SetupBase()
 {
     _compositionContainer = GetOrCreateCompositionContainer();
     _vim = _compositionContainer.GetExportedValue <IVim>();
     _vimBufferFactory               = _compositionContainer.GetExportedValue <IVimBufferFactory>();
     _textBufferFactoryService       = _compositionContainer.GetExportedValue <ITextBufferFactoryService>();
     _textEditorFactoryService       = _compositionContainer.GetExportedValue <ITextEditorFactoryService>();
     _vimErrorDetector               = _compositionContainer.GetExportedValue <IVimErrorDetector>();
     _commonOperationsFactory        = _compositionContainer.GetExportedValue <ICommonOperationsFactory>();
     _wordUtilFactory                = _compositionContainer.GetExportedValue <IWordUtilFactory>();
     _bufferTrackingService          = _compositionContainer.GetExportedValue <IBufferTrackingService>();
     _foldManagerFactory             = _compositionContainer.GetExportedValue <IFoldManagerFactory>();
     _smartIndentationService        = _compositionContainer.GetExportedValue <ISmartIndentationService>();
     _editorOperationsFactoryService = _compositionContainer.GetExportedValue <IEditorOperationsFactoryService>();
     _vimErrorDetector.Clear();
     _protectedOperations = new ProtectedOperations(_vimErrorDetector);
 }
Example #3
0
 public void SetupBase()
 {
     _vimErrorDetector = EditorUtil.FactoryService.VimErrorDetector;
     _vimErrorDetector.Clear();
     _protectedOperations = new ProtectedOperations(_vimErrorDetector);
 }
Example #4
0
        public override void SetupBase()
        {
            base.SetupBase();
            _vim = CompositionContainer.GetExportedValue<IVim>();
            _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
            _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
            _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
            _wordUtilFactory = CompositionContainer.GetExportedValue<IWordUtilFactory>();
            _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
            _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
            _vimErrorDetector.Clear();
            _protectedOperations = new ProtectedOperations(_vimErrorDetector);

            // One setting we do differ on for a default is 'timeout'.  We don't want them interferring
            // with the reliability of tests.  The default is on but turn it off here to prevent any
            // problems
            _vim.GlobalSettings.Timeout = false;

            // Don't let the personal VimRc of the user interfere with the unit tests
            _vim.AutoLoadVimRc = false;

            _vim.VimData.LastShellCommand = FSharpOption<string>.None;
            _vim.VimData.LastCommand = FSharpOption<StoredCommand>.None;
        }
Example #5
0
 public void SetupBase()
 {
     _compositionContainer = GetOrCreateCompositionContainer();
     _vim = _compositionContainer.GetExportedValue<IVim>();
     _vimBufferFactory = _compositionContainer.GetExportedValue<IVimBufferFactory>();
     _textBufferFactoryService = _compositionContainer.GetExportedValue<ITextBufferFactoryService>();
     _textEditorFactoryService = _compositionContainer.GetExportedValue<ITextEditorFactoryService>();
     _vimErrorDetector = _compositionContainer.GetExportedValue<IVimErrorDetector>();
     _commonOperationsFactory = _compositionContainer.GetExportedValue<ICommonOperationsFactory>();
     _wordUtilFactory = _compositionContainer.GetExportedValue<IWordUtilFactory>();
     _bufferTrackingService = _compositionContainer.GetExportedValue<IBufferTrackingService>();
     _foldManagerFactory = _compositionContainer.GetExportedValue<IFoldManagerFactory>();
     _smartIndentationService = _compositionContainer.GetExportedValue<ISmartIndentationService>();
     _vimErrorDetector.Clear();
     _protectedOperations = new ProtectedOperations(_vimErrorDetector);
 }
Example #6
0
        public virtual void Dispose()
        {
            _vim.MarkMap.Clear();

            if (_vimErrorDetector.HasErrors())
            {
                var msg = String.Format("Extension Exception: {0}", _vimErrorDetector.GetErrors().First().Message);

                // Need to clear before we throw or every subsequent test will fail with the same error
                _vimErrorDetector.Clear();

                throw new Exception(msg);
            }
            _vimErrorDetector.Clear();

            _vim.VimData.SearchHistory.Reset();
            _vim.VimData.CommandHistory.Reset();
            _vim.VimData.LastCommand       = FSharpOption <StoredCommand> .None;
            _vim.VimData.LastShellCommand  = FSharpOption <string> .None;
            _vim.VimData.AutoCommands      = FSharpList <AutoCommand> .Empty;
            _vim.VimData.AutoCommandGroups = FSharpList <AutoCommandGroup> .Empty;

            _vim.KeyMap.ClearAll();
            _vim.KeyMap.IsZeroMappingEnabled = true;

            _vim.CloseAllVimBuffers();
            _vim.IsDisabled = false;

            // The majority of tests run without a VimRc file but a few do customize it for specific
            // test reasons.  Make sure it's consistent
            VimRcState = VimRcState.None;

            // Reset all of the global settings back to their default values.   Adds quite
            // a bit of sanity to the test bed
            foreach (var setting in _vim.GlobalSettings.AllSettings)
            {
                if (!setting.IsValueDefault && !setting.IsValueCalculated)
                {
                    _vim.GlobalSettings.TrySetValue(setting.Name, setting.DefaultValue);
                }
            }

            // Reset all of the register values to empty
            foreach (var name in _vim.RegisterMap.RegisterNames)
            {
                _vim.RegisterMap.GetRegister(name).UpdateValue("");
            }

            // Don't let recording persist across tests
            if (_vim.MacroRecorder.IsRecording)
            {
                _vim.MacroRecorder.StopRecording();
            }

            var vimHost = Vim.VimHost as MockVimHost;

            if (vimHost != null)
            {
                vimHost.ShouldCreateVimBufferImpl = false;
                vimHost.Clear();
            }

            VariableMap.Clear();
        }
Example #7
0
 public override void SetupBase()
 {
     base.SetupBase();
     _vim = CompositionContainer.GetExportedValue<IVim>();
     _vimBufferFactory = CompositionContainer.GetExportedValue<IVimBufferFactory>();
     _vimErrorDetector = CompositionContainer.GetExportedValue<IVimErrorDetector>();
     _commonOperationsFactory = CompositionContainer.GetExportedValue<ICommonOperationsFactory>();
     _wordUtilFactory = CompositionContainer.GetExportedValue<IWordUtilFactory>();
     _bufferTrackingService = CompositionContainer.GetExportedValue<IBufferTrackingService>();
     _foldManagerFactory = CompositionContainer.GetExportedValue<IFoldManagerFactory>();
     _vimErrorDetector.Clear();
     _protectedOperations = new ProtectedOperations(_vimErrorDetector);
 }
Example #8
0
        private void ResetState()
        {
            Vim.MarkMap.Clear();

            Vim.VimData.SearchHistory.Reset();
            Vim.VimData.CommandHistory.Reset();
            Vim.VimData.LastCommand       = FSharpOption <StoredCommand> .None;
            Vim.VimData.LastCommandLine   = "";
            Vim.VimData.LastShellCommand  = FSharpOption <string> .None;
            Vim.VimData.LastTextInsert    = FSharpOption <string> .None;
            Vim.VimData.AutoCommands      = FSharpList <AutoCommand> .Empty;
            Vim.VimData.AutoCommandGroups = FSharpList <AutoCommandGroup> .Empty;

            Vim.KeyMap.ClearAll();
            Vim.DigraphMap.Clear();
            Vim.KeyMap.IsZeroMappingEnabled = true;

            Vim.CloseAllVimBuffers();
            Vim.IsDisabled = false;

            // If digraphs were loaded, reload them.
            if (Vim.AutoLoadDigraphs)
            {
                DigraphUtil.AddToMap(Vim.DigraphMap, DigraphUtil.DefaultDigraphs);
            }

            // The majority of tests run without a VimRc file but a few do customize it for specific
            // test reasons.  Make sure it's consistent
            VimRcState = VimRcState.None;

            // Reset all of the global settings back to their default values.   Adds quite
            // a bit of sanity to the test bed
            foreach (var setting in Vim.GlobalSettings.Settings)
            {
                if (!setting.IsValueDefault && !setting.IsValueCalculated)
                {
                    Vim.GlobalSettings.TrySetValue(setting.Name, setting.DefaultValue);
                }
            }

            // Reset all of the register values to empty
            foreach (var name in Vim.RegisterMap.RegisterNames)
            {
                Vim.RegisterMap.GetRegister(name).UpdateValue("");
            }

            // Don't let recording persist across tests
            if (Vim.MacroRecorder.IsRecording)
            {
                Vim.MacroRecorder.StopRecording();
            }

            if (Vim.VimHost is MockVimHost vimHost)
            {
                vimHost.ShouldCreateVimBufferImpl = false;
                vimHost.Clear();
            }

            VariableMap.Clear();
            VimErrorDetector.Clear();
        }
Example #9
0
 public void SetupBase()
 {
     _vimErrorDetector = EditorUtil.FactoryService.VimErrorDetector;
     _vimErrorDetector.Clear();
 }