Ejemplo n.º 1
0
        protected HostFactoryTest()
        {
            _globalSettings = Vim.GlobalSettings;
            _mockFactory    = new MockRepository(MockBehavior.Strict);
            _synchronizer   = _mockFactory.Create <IEditorToSettingsSynchronizer>(MockBehavior.Strict);
            _synchronizer.Setup(x => x.SyncSetting(It.IsAny <SettingSyncData>()));
            _vsEditorAdaptersFactoryService = _mockFactory.Create <IVsEditorAdaptersFactoryService>();
            _vimApplicationSettings         = _mockFactory.Create <IVimApplicationSettings>(MockBehavior.Loose);

            var vsAdapter = _mockFactory.Create <IVsAdapter>();

            vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_vsEditorAdaptersFactoryService.Object);

            _hostFactory = new HostFactory(
                Vim,
                _vsEditorAdaptersFactoryService.Object,
                _mockFactory.Create <IDisplayWindowBrokerFactoryService>(MockBehavior.Loose).Object,
                _mockFactory.Create <ITextManager>(MockBehavior.Loose).Object,
                vsAdapter.Object,
                ProtectedOperations,
                new VimBufferCoordinatorFactory(Vim),
                _mockFactory.Create <IKeyUtil>(MockBehavior.Loose).Object,
                _synchronizer.Object,
                _vimApplicationSettings.Object,
                new Lazy <ICommandTargetFactory, IOrderable>[] { });
        }
Ejemplo n.º 2
0
 private void Create(params string[] lines)
 {
     _textView       = EditorUtil.CreateView(lines);
     _globalSettings = new Vim.GlobalSettings();
     _globalSettings.IncrementalSearch = true;
     _globalSettings.WrapScan          = true;
     _localSettings = new LocalSettings(_globalSettings, _textView);
     _nav           = VimUtil.CreateTextStructureNavigator(_textView.TextBuffer);
     _factory       = new MockRepository(MockBehavior.Strict);
     _vimHost       = _factory.Create <IVimHost>();
     _vimHost.Setup(x => x.EnsureVisible(_textView, It.IsAny <SnapshotPoint>()));
     _statusUtil = _factory.Create <IStatusUtil>();
     _statusUtil.Setup(x => x.OnWarning(Resources.Common_SearchBackwardWrapped));
     _statusUtil.Setup(x => x.OnWarning(Resources.Common_SearchForwardWrapped));
     _vimData    = new VimData();
     _operations = VimUtil.CreateCommonOperations(
         textView: _textView,
         localSettings: _localSettings,
         vimHost: _vimHost.Object,
         statusUtil: _statusUtil.Object);
     _searchRaw = new IncrementalSearch(
         _operations,
         _localSettings,
         _nav,
         _statusUtil.Object,
         _vimData);
     _search = _searchRaw;
 }
Ejemplo n.º 3
0
 public VimTest()
 {
     _factory        = new MockRepository(MockBehavior.Strict);
     _globalSettings = new GlobalSettings();
     _markMap        = _factory.Create <IMarkMap>(MockBehavior.Strict);
     _fileSystem     = _factory.Create <IFileSystem>(MockBehavior.Strict);
     _bufferFactory  = VimBufferFactory;
     _keyMap         = new KeyMap(_globalSettings);
     _vimHost        = _factory.Create <IVimHost>(MockBehavior.Strict);
     _searchInfo     = _factory.Create <ISearchService>(MockBehavior.Strict);
     _vimRaw         = new Vim(
         _vimHost.Object,
         _bufferFactory,
         FSharpList <Lazy <IVimBufferCreationListener> > .Empty,
         _globalSettings,
         _markMap.Object,
         _keyMap,
         MockObjectFactory.CreateClipboardDevice().Object,
         _searchInfo.Object,
         _fileSystem.Object,
         new VimData(),
         _factory.Create <IBulkOperations>().Object);
     _vim = _vimRaw;
     _vim.AutoLoadVimRc = false;
 }
Ejemplo n.º 4
0
 private void Create(ITextView textView)
 {
     _textView = textView;
     _textBuffer = textView.TextBuffer;
     _buffer = _textView.TextBuffer;
     _snapshot = _buffer.CurrentSnapshot;
     _buffer.Changed += delegate { _snapshot = _buffer.CurrentSnapshot; };
     _globalSettings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_globalSettings, _textView);
     _markMap = new MarkMap(new TrackingLineColumnService());
     _vimData = new VimData();
     _search = VimUtil.CreateSearchService(_globalSettings);
     _jumpList = VimUtil.CreateJumpList();
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _navigator = VimUtil.CreateTextStructureNavigator(_textView.TextBuffer);
     _motionUtil = new MotionUtil(
         _textView,
         _markMap,
         _localSettings,
         _search,
         _navigator,
         _jumpList,
         _statusUtil.Object,
         _vimData);
 }
Ejemplo n.º 5
0
        protected void Create(bool insertMode, params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _factory.DefaultValue = DefaultValue.Mock;
            _textView             = CreateTextView(lines);
            _textBuffer           = _textView.TextBuffer;
            _vim               = _factory.Create <IVim>(MockBehavior.Loose);
            _editorOptions     = _factory.Create <IEditorOptions>(MockBehavior.Loose);
            _textChangeTracker = _factory.Create <ITextChangeTracker>(MockBehavior.Loose);
            _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption <TextChange> .None);
            _undoRedoOperations = new UndoRedoOperations(VimHost, new StatusUtil(), FSharpOption <ITextUndoHistory> .None, null);
            _wordCompletionSessionFactoryService = _factory.Create <IWordCompletionSessionFactoryService>();

            var localSettings = new LocalSettings(Vim.GlobalSettings);

            _vimBuffer      = Vim.CreateVimBuffer(_textView);
            _globalSettings = _vimBuffer.GlobalSettings;
            var vimTextBuffer = Vim.GetOrCreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);

            _operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _broker     = _factory.Create <IDisplayWindowBroker>();
            _broker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _broker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _insertUtil  = _factory.Create <IInsertUtil>();
            _motionUtil  = _factory.Create <IMotionUtil>();
            _commandUtil = _factory.Create <ICommandUtil>();
            _capture     = _factory.Create <IMotionCapture>();

            // Setup the mouse.  By default we say it has no buttons down as that's the normal state
            _mouseDevice = _factory.Create <IMouseDevice>();
            _mouseDevice.SetupGet(x => x.IsLeftButtonPressed).Returns(false);

            // Setup the keyboard.  By default we don't say that any button is pressed.  Insert mode is usually
            // only concerned with arrow keys and we will set those up as appropriate for the typing tests
            _keyboardDevice = _factory.Create <IKeyboardDevice>();
            _keyboardDevice.Setup(x => x.IsArrowKeyDown).Returns(false);

            _modeRaw = new global::Vim.Modes.Insert.InsertMode(
                _vimBuffer,
                _operations,
                _broker.Object,
                _editorOptions.Object,
                _undoRedoOperations,
                _textChangeTracker.Object,
                _insertUtil.Object,
                _motionUtil.Object,
                _commandUtil.Object,
                _capture.Object,
                !insertMode,
                _keyboardDevice.Object,
                _mouseDevice.Object,
                WordUtil,
                _wordCompletionSessionFactoryService.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
            _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; };
        }
Ejemplo n.º 6
0
 private void Create(ITextView textView, IEditorOptions editorOptions = null)
 {
     _textView = textView;
     _textBuffer = textView.TextBuffer;
     _snapshot = _textBuffer.CurrentSnapshot;
     _textBuffer.Changed += delegate { _snapshot = _textBuffer.CurrentSnapshot; };
     _globalSettings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_globalSettings, FSharpOption.CreateForReference(editorOptions), FSharpOption.CreateForReference(textView));
     _markMap = new MarkMap(new TrackingLineColumnService());
     _vimData = new VimData();
     _search = VimUtil.CreateSearchService(_globalSettings);
     _jumpList = VimUtil.CreateJumpList();
     _statusUtil = new Mock<IStatusUtil>(MockBehavior.Strict);
     _navigator = VimUtil.CreateTextStructureNavigator(_textView, WordKind.NormalWord);
     _motionUtil = new MotionUtil(
         _textView,
         _markMap,
         _localSettings,
         _search,
         _navigator,
         _jumpList,
         _statusUtil.Object,
         VimUtil.GetWordUtil(textView),
         _vimData);
 }
Ejemplo n.º 7
0
        protected VimTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _globalSettings = new GlobalSettings();
            _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
            _bufferFactory = VimBufferFactory;
            _simpleListener = new SimpleListener();
            var creationListeners = new [] { new Lazy<IVimBufferCreationListener>(() => _simpleListener) };

            var map = new Dictionary<string, VariableValue>();
            _keyMap = new KeyMap(_globalSettings, map);
            _vimHost = _factory.Create<IVimHost>(MockBehavior.Strict);
            _vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView());
            _vimHost.Setup(x => x.AutoSynchronizeSettings).Returns(true);
            _vimRaw = new Vim(
                _vimHost.Object,
                _bufferFactory,
                CompositionContainer.GetExportedValue<IVimInterpreterFactory>(),
                creationListeners.ToFSharpList(),
                _globalSettings,
                _factory.Create<IMarkMap>().Object,
                _keyMap,
                MockObjectFactory.CreateClipboardDevice().Object,
                _factory.Create<ISearchService>().Object,
                _fileSystem.Object,
                new VimData(_globalSettings),
                _factory.Create<IBulkOperations>().Object,
                map,
                new EditorToSettingSynchronizer());
            _vim = _vimRaw;
            _vim.AutoLoadVimRc = false;
        }
Ejemplo n.º 8
0
        protected VimTest()
        {
            _factory        = new MockRepository(MockBehavior.Strict);
            _globalSettings = new GlobalSettings();
            _fileSystem     = _factory.Create <IFileSystem>(MockBehavior.Strict);
            _bufferFactory  = VimBufferFactory;
            _simpleListener = new SimpleListener();
            var creationListeners = new [] { new Lazy <IVimBufferCreationListener>(() => _simpleListener) };

            var map = new Dictionary <string, VariableValue>();

            _keyMap  = new KeyMap(_globalSettings, map);
            _vimHost = _factory.Create <IVimHost>(MockBehavior.Strict);
            _vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView());
            _vimHost.Setup(x => x.AutoSynchronizeSettings).Returns(true);
            _vimRaw = new Vim(
                _vimHost.Object,
                _bufferFactory,
                CompositionContainer.GetExportedValue <IVimInterpreterFactory>(),
                creationListeners.ToFSharpList(),
                _globalSettings,
                _factory.Create <IMarkMap>().Object,
                _keyMap,
                MockObjectFactory.CreateClipboardDevice().Object,
                _factory.Create <ISearchService>().Object,
                _fileSystem.Object,
                new VimData(),
                _factory.Create <IBulkOperations>().Object,
                map,
                new EditorToSettingSynchronizer());
            _vim = _vimRaw;
            _vim.AutoLoadVimRc = false;
        }
Ejemplo n.º 9
0
 internal static void Initialize(IVimGlobalSettings globalSettings, IVimApplicationSettings vimApplicationSettings)
 {
     var settingsSource = new SettingsSource(vimApplicationSettings);
     globalSettings.AddCustomSetting(UseEditorIndentName, UseEditorIndentName, settingsSource);
     globalSettings.AddCustomSetting(UseEditorDefaultsName, UseEditorDefaultsName, settingsSource);
     globalSettings.AddCustomSetting(UseEditorTabAndBackspaceName, UseEditorTabAndBackspaceName, settingsSource);
 }
Ejemplo n.º 10
0
 private void Create(params string[] lines)
 {
     _vimTextBuffer  = CreateVimTextBuffer(lines);
     _textBuffer     = _vimTextBuffer.TextBuffer;
     _localSettings  = _vimTextBuffer.LocalSettings;
     _globalSettings = _localSettings.GlobalSettings;
 }
Ejemplo n.º 11
0
 public void Setup()
 {
     _settings            = new Vim.GlobalSettings();
     _settings.IgnoreCase = true;
     _settings.SmartCase  = false;
     _factory             = new VimRegexFactory(_settings);
 }
Ejemplo n.º 12
0
        protected VimTest(bool createVim = true)
        {
            _factory        = new MockRepository(MockBehavior.Strict);
            _globalSettings = new GlobalSettings();
            _fileSystem     = _factory.Create <IFileSystem>(MockBehavior.Strict);
            _bufferFactory  = VimBufferFactory;
            _simpleListener = new SimpleListener();

            _variableMap = new Dictionary <string, VariableValue>();
            _keyMap      = new KeyMap(_globalSettings, _variableMap);
            _vimHost     = _factory.Create <IVimHost>(MockBehavior.Strict);
            _vimHost.Setup(x => x.ShouldIncludeRcFile(It.IsAny <VimRcPath>())).Returns(true);
            _vimHost.Setup(x => x.CreateHiddenTextView()).Returns(CreateTextView());
            _vimHost.Setup(x => x.AutoSynchronizeSettings).Returns(true);
            _vimHost.Setup(x => x.VimCreated(It.IsAny <IVim>()));
            _vimHost.Setup(x => x.GetName(It.IsAny <ITextBuffer>())).Returns("VimTest.cs");
            _vimHost.Setup(x => x.EnsurePackageLoaded());
            _vimHost.SetupGet(x => x.DefaultSettings).Returns(DefaultSettings.GVim74);
            _vimHost.Setup(x => x.DoActionWhenTextViewReady(It.IsAny <FSharpFunc <Unit, Unit> >(), It.IsAny <ITextView>()))
            .Callback((FSharpFunc <Unit, Unit> action, ITextView textView) => action.Invoke(null));
            if (createVim)
            {
                CreateVim();
            }
        }
Ejemplo n.º 13
0
        protected HostFactoryTest()
        {
            _globalSettings = Vim.GlobalSettings;
            _protectedOperations = new TestableProtectedOperations();
            _mockFactory = new MockRepository(MockBehavior.Strict);
            _synchronizer = _mockFactory.Create<IEditorToSettingsSynchronizer>(MockBehavior.Strict);
            _vsEditorAdaptersFactoryService = _mockFactory.Create<IVsEditorAdaptersFactoryService>();
            _vimApplicationSettings = _mockFactory.Create<IVimApplicationSettings>(MockBehavior.Loose);

            var vsAdapter = _mockFactory.Create<IVsAdapter>();
            vsAdapter.SetupGet(x => x.EditorAdapter).Returns(_vsEditorAdaptersFactoryService.Object);

            _hostFactory = new HostFactory(
                Vim,
                _vsEditorAdaptersFactoryService.Object,
                _mockFactory.Create<IDisplayWindowBrokerFactoryService>(MockBehavior.Loose).Object,
                _mockFactory.Create<ITextManager>(MockBehavior.Loose).Object,
                vsAdapter.Object,
                _protectedOperations,
                new VimBufferCoordinatorFactory(Vim),
                _mockFactory.Create<IKeyUtil>(MockBehavior.Loose).Object,
                _synchronizer.Object,
                _vimApplicationSettings.Object,
                new Lazy<ICommandTargetFactory, IOrderable>[] { });
        }
Ejemplo n.º 14
0
 protected void Create(params string[] lines)
 {
     _textView       = CreateTextView(lines);
     _textBuffer     = _textView.TextBuffer;
     _vimBuffer      = Vim.CreateVimBuffer(_textView);
     _globalSettings = Vim.GlobalSettings;
 }
Ejemplo n.º 15
0
 public KeyMapTest()
 {
     _globalSettings = new GlobalSettings();
     _variableMap = new Dictionary<string, VariableValue>();
     _mapRaw = new KeyMap(_globalSettings, _variableMap);
     _map = _mapRaw;
 }
Ejemplo n.º 16
0
 public KeyMapTest()
 {
     _globalSettings = new GlobalSettings();
     _variableMap    = new Dictionary <string, VariableValue>();
     _mapRaw         = new KeyMap(_globalSettings, _variableMap);
     _map            = _mapRaw;
 }
Ejemplo n.º 17
0
 protected void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
     _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
     VimHost.FocusedTextView = _textView;
 }
 public void Setup()
 {
     _synchronizer = new EditorToSettingSynchronizer(EditorUtil.FactoryService.Vim);
     _buffer = EditorUtil.FactoryService.Vim.CreateBuffer(EditorUtil.CreateTextView(""));
     _localSettings = _buffer.LocalSettings;
     _globalSettings = _localSettings.GlobalSettings;
     _editorOptions = _localSettings.EditorOptions.Value;
 }
Ejemplo n.º 19
0
 protected void Create(params string[] lines)
 {
     _textView  = CreateTextView(lines);
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
     _globalSettings         = _vimBuffer.LocalSettings.GlobalSettings;
     VimHost.FocusedTextView = _textView;
 }
Ejemplo n.º 20
0
            internal static void Initialize(IVimGlobalSettings globalSettings, IVimApplicationSettings vimApplicationSettings)
            {
                var settingsSource = new SettingsSource(vimApplicationSettings);

                globalSettings.AddCustomSetting(UseEditorIndentName, UseEditorIndentName, settingsSource);
                globalSettings.AddCustomSetting(UseEditorDefaultsName, UseEditorDefaultsName, settingsSource);
                globalSettings.AddCustomSetting(UseEditorTabAndBackspaceName, UseEditorTabAndBackspaceName, settingsSource);
            }
Ejemplo n.º 21
0
 internal static Mock<IVimLocalSettings> CreateLocalSettings(
     IVimGlobalSettings global = null)
 {
     global = global ?? CreateGlobalSettings().Object;
     var mock = new Mock<IVimLocalSettings>(MockBehavior.Strict);
     mock.SetupGet(x => x.GlobalSettings).Returns(global);
     return mock;
 }
Ejemplo n.º 22
0
        protected void Create(bool insertMode, params string[] lines)
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _factory.DefaultValue = DefaultValue.Mock;
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vim = _factory.Create<IVim>(MockBehavior.Loose);
            _editorOptions = _factory.Create<IEditorOptions>(MockBehavior.Loose);
            _textChangeTracker = _factory.Create<ITextChangeTracker>(MockBehavior.Loose);
            _textChangeTracker.SetupGet(x => x.CurrentChange).Returns(FSharpOption<TextChange>.None);
            _undoRedoOperations = CreateUndoRedoOperations();
            _wordCompletionSessionFactoryService = _factory.Create<IWordCompletionSessionFactoryService>();

            var localSettings = new LocalSettings(Vim.GlobalSettings);
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _globalSettings = _vimBuffer.GlobalSettings;
            var vimTextBuffer = Vim.GetOrCreateVimTextBuffer(_textView.TextBuffer);
            var vimBufferData = CreateVimBufferData(vimTextBuffer, _textView);
            _operations = CommonOperationsFactory.GetCommonOperations(vimBufferData);
            _broker = _factory.Create<IDisplayWindowBroker>();
            _broker.SetupGet(x => x.IsCompletionActive).Returns(false);
            _broker.SetupGet(x => x.IsQuickInfoActive).Returns(false);
            _broker.SetupGet(x => x.IsSignatureHelpActive).Returns(false);
            _broker.SetupGet(x => x.IsSmartTagSessionActive).Returns(false);
            _insertUtil = _factory.Create<IInsertUtil>();
            _motionUtil = _factory.Create<IMotionUtil>();
            _commandUtil = _factory.Create<ICommandUtil>();
            _capture = _factory.Create<IMotionCapture>();

            // Setup the mouse.  By default we say it has no buttons down as that's the normal state
            _mouseDevice = _factory.Create<IMouseDevice>();
            _mouseDevice.SetupGet(x => x.IsLeftButtonPressed).Returns(false);

            // Setup the keyboard.  By default we don't say that any button is pressed.  Insert mode is usually
            // only concerned with arrow keys and we will set those up as appropriate for the typing tests
            _keyboardDevice = _factory.Create<IKeyboardDevice>();
            _keyboardDevice.Setup(x => x.IsArrowKeyDown).Returns(false);

            _modeRaw = new global::Vim.Modes.Insert.InsertMode(
                _vimBuffer,
                _operations,
                _broker.Object,
                _editorOptions.Object,
                _undoRedoOperations,
                _textChangeTracker.Object,
                _insertUtil.Object,
                _motionUtil.Object,
                _commandUtil.Object,
                _capture.Object,
                !insertMode,
                _keyboardDevice.Object,
                _mouseDevice.Object,
                WordUtil,
                _wordCompletionSessionFactoryService.Object);
            _mode = _modeRaw;
            _mode.OnEnter(ModeArgument.None);
            _mode.CommandRan += (sender, e) => { _lastCommandRan = e.CommandRunData; };
        }
        public EditorToSettingSynchronizerTest()
        {
            _synchronizer = new EditorToSettingSynchronizer(EditorOptionsFactoryService, Vim);

            _buffer = CreateVimBuffer("");
            _localSettings = _buffer.LocalSettings;
            _globalSettings = _localSettings.GlobalSettings;
            _editorOptions = _buffer.TextView.Options;
        }
Ejemplo n.º 24
0
 private void Create(VisualKind kind, int caretPosition, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.MoveCaretTo(caretPosition);
     _globalSettings    = new GlobalSettings();
     _incrementalSearch = new Mock <IIncrementalSearch>(MockBehavior.Loose);
     _tracker           = new SelectionTracker(_textView, _globalSettings, _incrementalSearch.Object, kind);
     _tracker.Start();
 }
Ejemplo n.º 25
0
        public EditorToSettingSynchronizerTest()
        {
            _synchronizer = new EditorToSettingSynchronizer(EditorOptionsFactoryService, Vim);

            _buffer         = CreateVimBuffer("");
            _localSettings  = _buffer.LocalSettings;
            _globalSettings = _localSettings.GlobalSettings;
            _editorOptions  = _buffer.TextView.Options;
        }
Ejemplo n.º 26
0
 public VimRcTest()
 {
     _vim                = (Vim)Vim;
     _globalSettings     = Vim.GlobalSettings;
     _fileSystem         = new Mock <IFileSystem>();
     _originalFileSystem = _vim._fileSystem;
     _vim._fileSystem    = _fileSystem.Object;
     VimHost.CreateHiddenTextViewFunc = () => TextEditorFactoryService.CreateTextView();
 }
 private void Create(params string[] lines)
 {
     _globalSettings = Vim.GlobalSettings;
     _vimBuffer = CreateVimBuffer(lines);
     _textView = (IWpfTextView)_vimBuffer.TextView;
     _textBuffer = _vimBuffer.TextBuffer;
     _commonOperationsRaw = (CommonOperations)CommonOperationsFactory.GetCommonOperations(_vimBuffer.VimBufferData);
     _commonOperations = _commonOperationsRaw;
 }
Ejemplo n.º 28
0
 private void Create(params string[] lines)
 {
     _globalSettings      = Vim.GlobalSettings;
     _vimBuffer           = CreateVimBuffer(lines);
     _textView            = (IWpfTextView)_vimBuffer.TextView;
     _textBuffer          = _vimBuffer.TextBuffer;
     _commonOperationsRaw = (CommonOperations)CommonOperationsFactory.GetCommonOperations(_vimBuffer.VimBufferData);
     _commonOperations    = _commonOperationsRaw;
 }
Ejemplo n.º 29
0
 protected void Create(ModeArgument argument, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _vimBuffer = Vim.CreateVimBuffer(_textView);
     _vimBuffer.SwitchMode(ModeKind.Insert, argument);
     _register = Vim.RegisterMap.GetRegister('c');
     _globalSettings = Vim.GlobalSettings;
     _localSettings = _vimBuffer.LocalSettings;
 }
Ejemplo n.º 30
0
 protected void Create(ModeArgument argument, params string[] lines)
 {
     _textView   = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _vimBuffer  = Vim.CreateVimBuffer(_textView);
     _vimBuffer.SwitchMode(ModeKind.Insert, argument);
     _register       = Vim.RegisterMap.GetRegister('c');
     _globalSettings = Vim.GlobalSettings;
     _localSettings  = _vimBuffer.LocalSettings;
 }
        public void Setup()
        {
            _synchronizer = new EditorToSettingSynchronizer(EditorUtil.FactoryService.EditorOptionsFactory, EditorUtil.FactoryService.Vim);

            var textView = EditorUtil.CreateTextView("");
            _buffer = EditorUtil.FactoryService.Vim.CreateVimBuffer(textView);
            _localSettings = _buffer.LocalSettings;
            _globalSettings = _localSettings.GlobalSettings;
            _editorOptions = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView);
        }
Ejemplo n.º 32
0
 public VimRcTest()
 {
     _vim            = (Vim)Vim;
     _globalSettings = Vim.GlobalSettings;
     _fileSystem     = new Mock <IFileSystem>();
     _fileSystem.Setup(x => x.GetVimRcDirectories()).Returns(new string[] { });
     _originalFileSystem = _vim.FileSystem;
     _vim.FileSystem     = _fileSystem.Object;
     VimHost.CreateHiddenTextViewFunc = () => TextEditorFactoryService.CreateTextView();
 }
Ejemplo n.º 33
0
 public static Mock<IVimLocalSettings> CreateLocalSettings(
     IVimGlobalSettings global = null,
     MockRepository factory = null)
 {
     factory = factory ?? new MockRepository(MockBehavior.Strict);
     global = global ?? CreateGlobalSettings(factory: factory).Object;
     var mock = factory.Create<IVimLocalSettings>(MockBehavior.Strict);
     mock.SetupGet(x => x.GlobalSettings).Returns(global);
     return mock;
 }
Ejemplo n.º 34
0
 public void Create(params string[] lines)
 {
     _textView       = EditorUtil.CreateView(lines);
     _buffer         = EditorUtil.FactoryService.Vim.CreateBuffer(_textView);
     _globalSettings = _buffer.Settings.GlobalSettings;
     _globalSettings.IncrementalSearch = true;
     _globalSettings.WrapScan          = true;
     _search    = _buffer.IncrementalSearch;
     _taggerRaw = new IncrementalSearchTagger(_buffer);
     _tagger    = _taggerRaw;
 }
Ejemplo n.º 35
0
        public static Mock <IVimLocalSettings> CreateLocalSettings(
            IVimGlobalSettings global = null,
            MockRepository factory    = null)
        {
            factory = factory ?? new MockRepository(MockBehavior.Strict);
            global  = global ?? CreateGlobalSettings(factory: factory).Object;
            var mock = factory.Create <IVimLocalSettings>(MockBehavior.Strict);

            mock.SetupGet(x => x.GlobalSettings).Returns(global);
            return(mock);
        }
Ejemplo n.º 36
0
 protected void Create(params string[] lines)
 {
     _vimBuffer = CreateVimBuffer(lines);
     _textView = _vimBuffer.TextView;
     _textBuffer = _vimBuffer.TextBuffer;
     _globalSettings = _vimBuffer.GlobalSettings;
     _globalSettings.SelectModeOptions = SelectModeOptions.Mouse | SelectModeOptions.Keyboard;
     _textSelection = _textView.Selection;
     _context = new TestableSynchronizationContext();
     _context.Install();
 }
Ejemplo n.º 37
0
            internal static void Initialize(IVimGlobalSettings globalSettings, IVimApplicationSettings vimApplicationSettings)
            {
                var settingsSource = new SettingsSource(vimApplicationSettings);

                globalSettings.AddCustomSetting(UseEditorIndentName, UseEditorIndentName, settingsSource);
                globalSettings.AddCustomSetting(UseEditorDefaultsName, UseEditorDefaultsName, settingsSource);
                globalSettings.AddCustomSetting(UseEditorTabAndBackspaceName, UseEditorTabAndBackspaceName, settingsSource);
                globalSettings.AddCustomSetting(UseEditorCommandMarginName, UseEditorCommandMarginName, settingsSource);
                globalSettings.AddCustomSetting(CleanMacrosName, CleanMacrosName, settingsSource);
                globalSettings.AddCustomSetting(HideMarksName, HideMarksName, settingsSource);
            }
Ejemplo n.º 38
0
 protected virtual void Create(params string[] lines)
 {
     _vimBuffer      = CreateVimBuffer(lines);
     _textView       = _vimBuffer.TextView;
     _textBuffer     = _vimBuffer.TextBuffer;
     _globalSettings = _vimBuffer.GlobalSettings;
     _globalSettings.SelectModeOptions = SelectModeOptions.Mouse | SelectModeOptions.Keyboard;
     _textSelection = _textView.Selection;
     _context       = new TestableSynchronizationContext();
     _context.Install();
 }
Ejemplo n.º 39
0
 public void Create(ITextView textView)
 {
     _textView = textView;
     _buffer = _textView.TextBuffer;
     _snapshot = _buffer.CurrentSnapshot;
     _buffer.Changed += delegate { _snapshot = _buffer.CurrentSnapshot; };
     _settings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_settings, _textView);
     _utilRaw = new TextViewMotionUtil(_textView, _localSettings);
     _util = _utilRaw;
 }
Ejemplo n.º 40
0
        public void Setup()
        {
            _synchronizer = new EditorToSettingSynchronizer(EditorUtil.FactoryService.EditorOptionsFactory, EditorUtil.FactoryService.Vim);

            var textView = EditorUtil.CreateTextView("");

            _buffer         = EditorUtil.FactoryService.Vim.CreateVimBuffer(textView);
            _localSettings  = _buffer.LocalSettings;
            _globalSettings = _localSettings.GlobalSettings;
            _editorOptions  = EditorUtil.FactoryService.EditorOptionsFactory.GetOptions(textView);
        }
Ejemplo n.º 41
0
 internal void Create(params string[] lines)
 {
     _vimBuffer      = CreateVimBuffer(lines);
     _textView       = _vimBuffer.TextView;
     _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
     _globalSettings.IncrementalSearch = true;
     _globalSettings.WrapScan          = true;
     _search          = _vimBuffer.IncrementalSearch;
     _taggerSourceRaw = new IncrementalSearchTaggerSource(_vimBuffer);
     _taggerSource    = _taggerSourceRaw;
 }
Ejemplo n.º 42
0
        internal CharDisplayTaggerSource(ITextView textView, IEditorFormatMap editorFormatMap, IVimGlobalSettings globalSettings)
        {
            _textView        = textView;
            _editorFormatMap = editorFormatMap;
            _globalSettings  = globalSettings;
            UpdateBrushes();

            _textView.TextBuffer.Changed          += OnTextBufferChanged;
            _editorFormatMap.FormatMappingChanged += OnFormatMappingChanged;
            _globalSettings.SettingChanged        += OnSettingChanged;
        }
Ejemplo n.º 43
0
        /// <summary>
        /// Create the IVimBuffer with the given set of lines.  Note that we intentionally don't
        /// set the mode to Insert here because the given commands should work irrespective of the 
        /// mode
        /// </summary>
        /// <param name="lines"></param>
        private void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _buffer = Vim.CreateVimBuffer(_textView);
            _globalSettings = _buffer.GlobalSettings;
            _localSettings = _buffer.LocalSettings;

            var operations = CommonOperationsFactory.GetCommonOperations(_buffer.VimBufferData);
            _insertUtilRaw = new InsertUtil(_buffer.VimBufferData, operations);
            _insertUtil = _insertUtilRaw;
        }
 public void Create(params string[] lines)
 {
     _vimBuffer = CreateVimBuffer(lines);
     _textView = _vimBuffer.TextView;
     _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
     _globalSettings.IncrementalSearch = true;
     _globalSettings.WrapScan = true;
     _search = _vimBuffer.IncrementalSearch;
     _taggerSourceRaw = new IncrementalSearchTaggerSource(_vimBuffer);
     _taggerSource = _taggerSourceRaw;
 }
Ejemplo n.º 45
0
 public void Create(params string[] lines)
 {
     _textView = EditorUtil.CreateTextView(lines);
     _buffer = EditorUtil.FactoryService.Vim.CreateBuffer(_textView);
     _globalSettings = _buffer.LocalSettings.GlobalSettings;
     _globalSettings.IncrementalSearch = true;
     _globalSettings.WrapScan = true;
     _search = _buffer.IncrementalSearch;
     _taggerRaw = new IncrementalSearchTagger(_buffer);
     _tagger = _taggerRaw;
 }
Ejemplo n.º 46
0
        protected VimRegexTest()
        {
            // This can't be simplified due to a bug in Roslyn. Suppressing the suggestion
            // until fixed
            // https://github.com/dotnet/roslyn/issues/23368
#pragma warning disable IDE0017
            _globalSettings = new GlobalSettings();
#pragma warning restore IDE0017
            _globalSettings.IgnoreCase = true;
            _globalSettings.SmartCase  = false;
        }
Ejemplo n.º 47
0
 protected virtual void Create(params string[] lines)
 {
     _vimBuffer      = CreateVimBuffer(lines);
     _textView       = _vimBuffer.TextView;
     _textBuffer     = _vimBuffer.TextBuffer;
     _globalSettings = _vimBuffer.GlobalSettings;
     _globalSettings.SelectModeOptions = SelectModeOptions.Mouse | SelectModeOptions.Keyboard;
     _textSelection       = _textView.Selection;
     _testableMouseDevice = (TestableMouseDevice)MouseDevice;
     _testableMouseDevice.IsLeftButtonPressed = true;
 }
Ejemplo n.º 48
0
        /// <summary>
        /// Create the IVimBuffer with the given set of lines.  Note that we intentionally don't
        /// set the mode to Insert here because the given commands should work irrespective of the 
        /// mode
        /// </summary>
        /// <param name="lines"></param>
        private void Create(params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _globalSettings = _vimBuffer.GlobalSettings;
            _localSettings = _vimBuffer.LocalSettings;

            var operations = CommonOperationsFactory.GetCommonOperations(_vimBuffer.VimBufferData);
            _insertUtilRaw = new InsertUtil(_vimBuffer.VimBufferData, operations);
            _insertUtil = _insertUtilRaw;
        }
Ejemplo n.º 49
0
 private void Create(VisualKind kind, int caretPosition, params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textView.MoveCaretTo(caretPosition);
     _globalSettings = new GlobalSettings();
     var localSettings = new LocalSettings(_globalSettings);
     var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(_textView.TextBuffer, localSettings);
     _vimBufferData = MockObjectFactory.CreateVimBufferData(vimTextBuffer.Object, _textView);
     _incrementalSearch = new Mock<IIncrementalSearch>(MockBehavior.Loose);
     _tracker = new SelectionTracker(_vimBufferData, _incrementalSearch.Object, kind);
     _tracker.Start();
 }
Ejemplo n.º 50
0
        internal ImeCoordinator(IVim vim)
        {
            _vim            = vim;
            _globalSettings = _vim.GlobalSettings;
            _inputModeState = new InputModeState(_vim.GlobalSettings);

            _inputMode = InputMode.None;

            _vim.GlobalSettings.SettingChanged += OnSettingChanged;

            AdjustImeState(_inputMode, _inputMode);
        }
Ejemplo n.º 51
0
        private void Create(VisualKind kind, int caretPosition, params string[] lines)
        {
            _textView = CreateTextView(lines);
            _textView.MoveCaretTo(caretPosition);
            _globalSettings = new GlobalSettings();
            var localSettings = new LocalSettings(_globalSettings);
            var vimTextBuffer = MockObjectFactory.CreateVimTextBuffer(_textView.TextBuffer, localSettings);

            _vimBufferData     = MockObjectFactory.CreateVimBufferData(vimTextBuffer.Object, _textView);
            _incrementalSearch = new Mock <IIncrementalSearch>(MockBehavior.Loose);
            _tracker           = new SelectionTracker(_vimBufferData, _incrementalSearch.Object, kind);
            _tracker.Start();
        }
Ejemplo n.º 52
0
 protected virtual void Create(params string[] lines)
 {
     _vimBuffer = CreateVimBuffer(lines);
     _textView = _vimBuffer.TextView;
     _textBuffer = _vimBuffer.TextBuffer;
     _globalSettings = _vimBuffer.GlobalSettings;
     _globalSettings.SelectModeOptions = SelectModeOptions.Mouse | SelectModeOptions.Keyboard;
     _textSelection = _textView.Selection;
     _context = new TestableSynchronizationContext();
     _context.Install();
     _testableMouseDevice = (TestableMouseDevice)MouseDevice;
     _testableMouseDevice.IsLeftButtonPressed = true;
 }
Ejemplo n.º 53
0
        public void Create(params string[] lines)
        {
            _textBuffer = EditorUtil.CreateTextBuffer(lines);
            _navigator = VimUtil.CreateTextStructureNavigator(_textBuffer, WordKind.NormalWord);
            _globalSettings = new Vim.GlobalSettings();
            _globalSettings.Magic = true;
            _globalSettings.IgnoreCase = true;
            _globalSettings.SmartCase = false;

            _textSearch = EditorUtil.FactoryService.TextSearchService;
            _searchRaw = new SearchService(_textSearch, _globalSettings);
            _search = _searchRaw;
        }
Ejemplo n.º 54
0
        public void Create(params string[] lines)
        {
            _textBuffer = CreateTextBuffer(lines);
            _wordNavigator = WordUtilFactory.GetWordUtil(_textBuffer).CreateTextStructureNavigator(WordKind.NormalWord);
            _globalSettings = Vim.GlobalSettings;
            _globalSettings.Magic = true;
            _globalSettings.IgnoreCase = true;
            _globalSettings.SmartCase = false;

            _textSearch = TextSearchService;
            _searchRaw = new SearchService(_textSearch, _globalSettings);
            _search = _searchRaw;
        }
Ejemplo n.º 55
0
        public virtual void Create(ITextSearchService textSearchService, params string[] lines)
        {
            _textBuffer = CreateTextBuffer(lines);
            _wordNavigator = WordUtil.CreateTextStructureNavigator(WordKind.NormalWord, _textBuffer.ContentType);
            _globalSettings = Vim.GlobalSettings;
            _globalSettings.Magic = true;
            _globalSettings.IgnoreCase = true;
            _globalSettings.SmartCase = false;

            _textSearch = textSearchService;
            _searchRaw = new SearchService(_textSearch, _globalSettings);
            _search = _searchRaw;
        }
 protected void Create(params string[] lines)
 {
     _textView = CreateTextView(lines);
     _textBuffer = _textView.TextBuffer;
     _globalSettings = Vim.GlobalSettings;
     _globalSettings.IgnoreCase = true;
     _globalSettings.HighlightSearch = true;
     _vimData = Vim.VimData;
     _asyncTaggerSourceRaw = new HighlightSearchTaggerSource(
         _textView,
         _globalSettings,
         _vimData,
         Vim.VimHost);
     _asyncTaggerSource = _asyncTaggerSourceRaw;
 }
Ejemplo n.º 57
0
 public void Create(ITextView textView)
 {
     _textView = textView;
     _buffer = _textView.TextBuffer;
     _snapshot = _buffer.CurrentSnapshot;
     _buffer.Changed += delegate { _snapshot = _buffer.CurrentSnapshot; };
     _settings = new Vim.GlobalSettings();
     _localSettings = new LocalSettings(_settings, _textView);
     _markMap = new MarkMap(new TrackingLineColumnService());
     _utilRaw = new TextViewMotionUtil(
         _textView,
         _markMap,
         _localSettings);
     _util = _utilRaw;
 }
Ejemplo n.º 58
0
 internal BlockCaretController(
     IVimBuffer buffer,
     IBlockCaret blockCaret)
 {
     _buffer = buffer;
     _blockCaret = blockCaret;
     _globalSettings = _buffer.LocalSettings.GlobalSettings;
     _buffer.SwitchedMode += OnCaretRelatedEvent;
     _buffer.KeyInputStart += OnCaretRelatedEvent;
     _buffer.KeyInputEnd += OnCaretRelatedEvent;
     _buffer.Closed += OnBufferClosed;
     _globalSettings.SettingChanged += OnSettingsChanged;
     UpdateCaretDisplay();
     UpdateCaretOpacity();
 }
Ejemplo n.º 59
0
        public void Create(params string[] lines)
        {
            _context = new TestableSynchronizationContext();
            SynchronizationContext.SetSynchronizationContext(_context);
            _textView = CreateTextView(lines);
            _textBuffer = _textView.TextBuffer;
            _vimBuffer = Vim.CreateVimBuffer(_textView);
            _vimBuffer.SwitchMode(ModeKind.Normal, ModeArgument.None);
            _vimTextBuffer = _vimBuffer.VimTextBuffer;
            _registerMap = _vimBuffer.RegisterMap;
            _globalSettings = _vimBuffer.LocalSettings.GlobalSettings;
            Assert.IsTrue(_context.IsEmpty);

            // Need to make sure it's focused so macro recording will work
            ((MockVimHost)_vimBuffer.Vim.VimHost).FocusedTextView = _textView;
        }
Ejemplo n.º 60
-1
        public VimTest()
        {
            _factory = new MockRepository(MockBehavior.Strict);
            _globalSettings = new GlobalSettings();
            _markMap = _factory.Create<IMarkMap>(MockBehavior.Strict);
            _fileSystem = _factory.Create<IFileSystem>(MockBehavior.Strict);
            _bufferFactory = VimBufferFactory;

            var map = new Dictionary<string, VariableValue>();
            _keyMap = new KeyMap(_globalSettings, map);
            _vimHost = _factory.Create<IVimHost>(MockBehavior.Strict);
            _searchInfo = _factory.Create<ISearchService>(MockBehavior.Strict);
            _vimRaw = new Vim(
                _vimHost.Object,
                _bufferFactory,
                FSharpList<Lazy<IVimBufferCreationListener>>.Empty,
                _globalSettings,
                _markMap.Object,
                _keyMap,
                MockObjectFactory.CreateClipboardDevice().Object,
                _searchInfo.Object,
                _fileSystem.Object,
                new VimData(),
                _factory.Create<IBulkOperations>().Object,
                map);
            _vim = _vimRaw;
            _vim.AutoLoadVimRc = false;
        }