diff --git a/CocoJumper.Base/CocoJumper.Base.csproj b/CocoJumper.Base/CocoJumper.Base.csproj
index 87019f5..90fb5e0 100644
--- a/CocoJumper.Base/CocoJumper.Base.csproj
+++ b/CocoJumper.Base/CocoJumper.Base.csproj
@@ -80,6 +80,7 @@
+
diff --git a/CocoJumper.Base/EventModels/SearchResultEvent.cs b/CocoJumper.Base/EventModels/SearchResultEvent.cs
index 4954246..9832d5c 100644
--- a/CocoJumper.Base/EventModels/SearchResultEvent.cs
+++ b/CocoJumper.Base/EventModels/SearchResultEvent.cs
@@ -1,15 +1,16 @@
-using System.Collections.Generic;
-using System.Linq;
+using CocoJumper.Base.Events;
+using System.Collections.Generic;
-namespace CocoJumper.Base.Events
+namespace CocoJumper.Base.EventModels
{
public class SearchResultEvent
{
- public List SearchEvents;
-
public SearchResultEvent()
{
SearchEvents = new List();
}
+
+ public bool IsHighlightDisabled { get; set; }
+ public List SearchEvents { get; set; }
}
}
\ No newline at end of file
diff --git a/CocoJumper.Base/Exception/InvalidStateException.cs b/CocoJumper.Base/Exception/InvalidStateException.cs
new file mode 100644
index 0000000..1647b0c
--- /dev/null
+++ b/CocoJumper.Base/Exception/InvalidStateException.cs
@@ -0,0 +1,9 @@
+namespace CocoJumper.Base.Exception
+{
+ public class InvalidStateException : System.Exception
+ {
+ public InvalidStateException(string message) : base(message)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/CocoJumper.Base/Properties/AssemblyInfo.cs b/CocoJumper.Base/Properties/AssemblyInfo.cs
index 884899c..5569ed8 100644
--- a/CocoJumper.Base/Properties/AssemblyInfo.cs
+++ b/CocoJumper.Base/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.2.0")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("1.0.3.0")]
diff --git a/CocoJumper/CodeHighlighterTag/CodeHighlighterTagger.cs b/CocoJumper/CodeHighlighterTag/CodeHighlighterTagger.cs
index e057d67..8674fd0 100644
--- a/CocoJumper/CodeHighlighterTag/CodeHighlighterTagger.cs
+++ b/CocoJumper/CodeHighlighterTag/CodeHighlighterTagger.cs
@@ -6,6 +6,7 @@
using Microsoft.VisualStudio.Text.Tagging;
using System;
using System.Collections.Generic;
+using CocoJumper.Base.EventModels;
namespace CocoJumper.CodeHighlighterTag
{
@@ -50,7 +51,7 @@ private void OnSearch(SearchResultEvent e)
{
if (!_textView.HasAggregateFocus || _textView.IsClosed)
return;
- _searchEvents = e.SearchEvents;
+ _searchEvents = e.IsHighlightDisabled ? null : e.SearchEvents;
this.InvokeTagsChanged(TagsChanged, _buffer);
}
}
diff --git a/CocoJumper/Commands/CocoJumperCommandPackage.cs b/CocoJumper/Commands/CocoJumperCommandPackage.cs
index 7fd42c9..6f90536 100644
--- a/CocoJumper/Commands/CocoJumperCommandPackage.cs
+++ b/CocoJumper/Commands/CocoJumperCommandPackage.cs
@@ -62,5 +62,32 @@ public int AutomaticallyExitInterval
return page.AutomaticallyExitInterval;
}
}
+
+ public bool DisableHighlightForMultiSearch
+ {
+ get
+ {
+ CocoJumperOptions page = (CocoJumperOptions)GetDialogPage(typeof(CocoJumperOptions));
+ return page.DisableHighlightForMultiSearch;
+ }
+ }
+
+ public bool DisableHighlightForSingleHighlight
+ {
+ get
+ {
+ CocoJumperOptions page = (CocoJumperOptions)GetDialogPage(typeof(CocoJumperOptions));
+ return page.DisableHighlightForSingleHighlight;
+ }
+ }
+
+ public bool DisableHighlightForSingleSearch
+ {
+ get
+ {
+ CocoJumperOptions page = (CocoJumperOptions)GetDialogPage(typeof(CocoJumperOptions));
+ return page.DisableHighlightForSingleSearch;
+ }
+ }
}
}
\ No newline at end of file
diff --git a/CocoJumper/Commands/CocoJumperMultiSearchCommand.cs b/CocoJumper/Commands/CocoJumperMultiSearchCommand.cs
index 7c55591..aa15302 100644
--- a/CocoJumper/Commands/CocoJumperMultiSearchCommand.cs
+++ b/CocoJumper/Commands/CocoJumperMultiSearchCommand.cs
@@ -1,5 +1,7 @@
using CocoJumper.Base.Enum;
+using CocoJumper.Base.Events;
using CocoJumper.Base.Logic;
+using CocoJumper.Events;
using CocoJumper.Extensions;
using CocoJumper.Listeners;
using CocoJumper.Logic;
@@ -12,8 +14,6 @@
using Microsoft.VisualStudio.TextManager.Interop;
using System;
using System.ComponentModel.Design;
-using CocoJumper.Base.Events;
-using CocoJumper.Events;
using Task = System.Threading.Tasks.Task;
namespace CocoJumper.Commands
@@ -47,6 +47,7 @@ public static CocoJumperMultiSearchCommand Instance
get;
private set;
}
+
private IAsyncServiceProvider ServiceProvider => _package;
public static async Task InitializeAsync(AsyncPackage package)
@@ -79,11 +80,7 @@ private void Execute(object sender, EventArgs e)
CleanupLogicAndInputListener();
WpfViewProvider renderer = new WpfViewProvider(wpfTextView);
- _logic = new CocoJumperLogic(renderer,
- cocoJumperCommandPackage.LimitResults,
- cocoJumperCommandPackage.TimerInterval,
- cocoJumperCommandPackage.AutomaticallyExitInterval,
- cocoJumperCommandPackage.JumpAfterChoosedElement);
+ _logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage);
_inputListener = new InputListener(textView);
_inputListener.KeyPressEvent += OnKeyboardAction;
@@ -94,6 +91,7 @@ private void OnExit(ExitEvent e)
{
CleanupLogicAndInputListener();
}
+
private void OnKeyboardAction(object oSender, char? key, KeyEventType eventType)
{
_logic = _logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperMultiSearchCommand)}, {nameof(_logic)} is null");
diff --git a/CocoJumper/Commands/CocoJumperOptions.cs b/CocoJumper/Commands/CocoJumperOptions.cs
index d9a063e..bff74d9 100644
--- a/CocoJumper/Commands/CocoJumperOptions.cs
+++ b/CocoJumper/Commands/CocoJumperOptions.cs
@@ -7,35 +7,50 @@ namespace CocoJumper.Commands
public class CocoJumperOptions : DialogPage
{
private const string GeneralCategory = "General";
- private int _timerInterval = 250;
- private int _limitResults = 50;
- private int _automaticallyExitInterval = 5000;
- private bool _jumpAfterChoosedElement = false;
- [Category(GeneralCategory)]
- [DisplayName("Limit results")]
- [Description("Limts results that are rendered on one page.")]
- [DefaultValue(50)]
- public int LimitResults { get => _limitResults; set => _limitResults = value; }
-
- [Category(GeneralCategory)]
- [DisplayName("Timer interval(ms)")]
- [Description("Determines how much ms must pass before rendering components, counting from last key press.")]
- [DefaultValue(250)]
- public int TimerInterval { get => _timerInterval; set => _timerInterval = value; }
+ public event EventHandler Saved;
[Category(GeneralCategory)]
[DisplayName("Automatically exit after(ms)")]
[Description("Determines how much ms must pass before logic will automaticly exit.")]
[DefaultValue(5000)]
- public int AutomaticallyExitInterval { get => _automaticallyExitInterval; set => _automaticallyExitInterval = value; }
+ public int AutomaticallyExitInterval { get; set; } = 5000;
+
+ [Category(GeneralCategory)]
+ [DisplayName("Disable highlight for multisearch")]
+ [Description("If set to True, logic will not render any highlighting components with may slowdown VisualStudio.")]
+ [DefaultValue(false)]
+ public bool DisableHighlightForMultiSearch { get; set; } = false;
+
+ [Category(GeneralCategory)]
+ [DisplayName("Disable highlight for single search with select")]
+ [Description("If set to True, logic will not render any highlighting components with may slowdown VisualStudio.")]
+ [DefaultValue(false)]
+ public bool DisableHighlightForSingleHighlight { get; set; } = false;
+ [Category(GeneralCategory)]
+ [DisplayName("Disable highlight for single search")]
+ [Description("If set to True, logic will not render any highlighting components with may slowdown VisualStudio.")]
+ [DefaultValue(false)]
+ public bool DisableHighlightForSingleSearch { get; set; } = false;
[Category(GeneralCategory)]
[DisplayName("Jump after choosed element")]
[Description("If set to True, logic will move caret to the end of choosed element.")]
[DefaultValue(false)]
- public bool JumpAfterChoosedElement { get => _jumpAfterChoosedElement; set => _jumpAfterChoosedElement = value; }
+ public bool JumpAfterChoosedElement { get; set; } = false;
+
+ [Category(GeneralCategory)]
+ [DisplayName("Limit results")]
+ [Description("Limts results that are rendered on one page.")]
+ [DefaultValue(50)]
+ public int LimitResults { get; set; } = 50;
+
+ [Category(GeneralCategory)]
+ [DisplayName("Timer interval(ms)")]
+ [Description("Determines how much ms must pass before rendering components, counting from last key press.")]
+ [DefaultValue(250)]
+ public int TimerInterval { get; set; } = 250;
public override void SaveSettingsToStorage()
{
@@ -49,7 +64,5 @@ public override void SaveSettingsToStorage()
Saved?.Invoke(this, EventArgs.Empty);
}
-
- public event EventHandler Saved;
}
}
\ No newline at end of file
diff --git a/CocoJumper/Commands/CocoJumperSingleSearchCommand.cs b/CocoJumper/Commands/CocoJumperSingleSearchCommand.cs
index b0d0675..ace73d2 100644
--- a/CocoJumper/Commands/CocoJumperSingleSearchCommand.cs
+++ b/CocoJumper/Commands/CocoJumperSingleSearchCommand.cs
@@ -88,11 +88,7 @@ private void Execute(object sender, EventArgs e)
CleanupLogicAndInputListener();
WpfViewProvider renderer = new WpfViewProvider(wpfTextView);
- _logic = new CocoJumperLogic(renderer,
- cocoJumperCommandPackage.LimitResults,
- cocoJumperCommandPackage.TimerInterval,
- cocoJumperCommandPackage.AutomaticallyExitInterval,
- cocoJumperCommandPackage.JumpAfterChoosedElement);
+ _logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage);
_inputListener = new InputListener(textView);
_inputListener.KeyPressEvent += OnKeyboardAction;
_logic.ActivateSearching(true, false);
@@ -102,6 +98,7 @@ private void OnExit(ExitEvent e)
{
CleanupLogicAndInputListener();
}
+
private void OnKeyboardAction(object oSender, char? key, KeyEventType eventType)
{
_logic = _logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperMultiSearchCommand)}, {nameof(_logic)} is null");
diff --git a/CocoJumper/Commands/CocoJumperSingleSearchHighlightCommand.cs b/CocoJumper/Commands/CocoJumperSingleSearchHighlightCommand.cs
index c2eb28b..817f6ce 100644
--- a/CocoJumper/Commands/CocoJumperSingleSearchHighlightCommand.cs
+++ b/CocoJumper/Commands/CocoJumperSingleSearchHighlightCommand.cs
@@ -48,13 +48,7 @@ public static CocoJumperSingleSearchHighlightCommand Instance
private set;
}
- private IAsyncServiceProvider ServiceProvider
- {
- get
- {
- return _package;
- }
- }
+ private IAsyncServiceProvider ServiceProvider => _package;
public static async Task InitializeAsync(AsyncPackage package)
{
@@ -87,11 +81,7 @@ private void Execute(object sender, EventArgs e)
CleanupLogicAndInputListener();
WpfViewProvider renderer = new WpfViewProvider(wpfTextView);
- _logic = new CocoJumperLogic(renderer,
- cocoJumperCommandPackage.LimitResults,
- cocoJumperCommandPackage.TimerInterval,
- cocoJumperCommandPackage.AutomaticallyExitInterval,
- cocoJumperCommandPackage.JumpAfterChoosedElement);
+ _logic = new CocoJumperLogic(renderer, cocoJumperCommandPackage);
_inputListener = new InputListener(textView);
_inputListener.KeyPressEvent += OnKeyboardAction;
_logic.ActivateSearching(true, true);
@@ -101,6 +91,7 @@ private void OnExit(ExitEvent e)
{
CleanupLogicAndInputListener();
}
+
private void OnKeyboardAction(object oSender, char? key, KeyEventType eventType)
{
_logic = _logic ?? throw new Exception($"{nameof(OnKeyboardAction)} in {nameof(CocoJumperMultiSearchCommand)}, {nameof(_logic)} is null");
diff --git a/CocoJumper/Logic/CocoJumperLogic.cs b/CocoJumper/Logic/CocoJumperLogic.cs
index fd159d3..881691a 100644
--- a/CocoJumper/Logic/CocoJumperLogic.cs
+++ b/CocoJumper/Logic/CocoJumperLogic.cs
@@ -1,8 +1,11 @@
using CocoJumper.Base.Enum;
+using CocoJumper.Base.EventModels;
using CocoJumper.Base.Events;
+using CocoJumper.Base.Exception;
using CocoJumper.Base.Logic;
using CocoJumper.Base.Model;
using CocoJumper.Base.Provider;
+using CocoJumper.Commands;
using CocoJumper.Helpers;
using System;
using System.Collections.Generic;
@@ -13,7 +16,10 @@ namespace CocoJumper.Logic
{
public class CocoJumperLogic : ICocoJumperLogic
{
- private readonly bool _jumpAfterChoosedElement;
+ private readonly bool _disableMultiSearchHighlight;
+ private readonly bool _disableSingleSearchHighlight;
+ private readonly bool _disableSingleSearchSelectHighlight;
+ private readonly bool _jumpAfterChosenElement;
private readonly int _searchLimit;
private readonly List _searchResults;
private readonly DispatcherTimer _timer, _autoExitDispatcherTimer;
@@ -24,13 +30,16 @@ public class CocoJumperLogic : ICocoJumperLogic
private CocoJumperState _state;
private IWpfViewProvider _viewProvider;
- public CocoJumperLogic(IWpfViewProvider renderer, int searchLimit, int timeInterval, int automaticallyExitInterval, bool jumpAfterChoosedElement)
+ public CocoJumperLogic(IWpfViewProvider renderer, CocoJumperCommandPackage package)
{
_state = CocoJumperState.Inactive;
- _searchLimit = searchLimit;
- _jumpAfterChoosedElement = jumpAfterChoosedElement;
- _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(timeInterval) };
- _autoExitDispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(automaticallyExitInterval) };
+ _searchLimit = package.LimitResults;
+ _disableMultiSearchHighlight = package.DisableHighlightForMultiSearch;
+ _disableSingleSearchHighlight = package.DisableHighlightForSingleSearch;
+ _disableSingleSearchSelectHighlight = package.DisableHighlightForSingleHighlight;
+ _jumpAfterChosenElement = package.JumpAfterChoosedElement;
+ _timer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(package.TimerInterval) };
+ _autoExitDispatcherTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(package.AutomaticallyExitInterval) };
_autoExitDispatcherTimer.Tick += OnAutoExitTimerEvent;
_timer.Tick += OnTimerTick;
_searchResults = new List();
@@ -40,7 +49,8 @@ public CocoJumperLogic(IWpfViewProvider renderer, int searchLimit, int timeInter
public void ActivateSearching(bool isSingle, bool isHighlight)
{
if (_state != CocoJumperState.Inactive)
- throw new Exception($"{nameof(ActivateSearching)} in {nameof(CocoJumperLogic)}, state is in wrong state {_state}");
+ throw new InvalidStateException($"{nameof(ActivateSearching)} in {nameof(CocoJumperLogic)}, state is in wrong state {_state}");
+
_autoExitDispatcherTimer.Stop();
_autoExitDispatcherTimer.Start();
_state = CocoJumperState.Searching;
@@ -59,6 +69,8 @@ public void Dispose()
_autoExitDispatcherTimer.Tick -= OnAutoExitTimerEvent;
_timer.Stop();
_autoExitDispatcherTimer.Stop();
+
+ GC.SuppressFinalize(this);
}
public CocoJumperKeyboardActionResult KeyboardAction(char? key, KeyEventType eventType)
@@ -89,10 +101,17 @@ private static string RemoveLastChar(string text)
return text.Substring(0, text.Length - 1);
}
- private static void ThrowKeyPressWithNullKeyException(char? key = null)
+ private static void ThrowKeyPressWithNullKeyException()
+ {
+ throw new InvalidStateException(
+ $"{nameof(CocoJumperLogic)} is in wrong state, {nameof(KeyEventType.KeyPress)} was passed but key was null");
+ }
+
+ private bool IsHighlightDisabled()
{
- throw new Exception(
- $"{nameof(CocoJumperLogic)} is in wrong state, {nameof(KeyEventType.KeyPress)} was passed but {nameof(key)} was null");
+ return _disableSingleSearchHighlight && _isSingleSearch && !_isHighlight
+ || _disableMultiSearchHighlight && !_isSingleSearch && !_isHighlight
+ || _disableSingleSearchSelectHighlight && !_isSingleSearch && _isHighlight;
}
private void OnAutoExitTimerEvent(object sender, EventArgs e)
@@ -106,6 +125,7 @@ private void OnTimerTick(object sender, EventArgs e)
_timer.Stop();
EventHelper.EventHelperInstance.RaiseEvent(new SearchResultEvent
{
+ IsHighlightDisabled = IsHighlightDisabled(),
SearchEvents = _searchResults
.Select(p => new SearchEvent
{
@@ -161,7 +181,7 @@ private CocoJumperKeyboardActionResult PerformChoosing(char? key, KeyEventType e
}
else
{
- _viewProvider.MoveCaretTo(_jumpAfterChoosedElement ? isFinished.Position + isFinished.Length : isFinished.Position);
+ _viewProvider.MoveCaretTo(_jumpAfterChosenElement ? isFinished.Position + isFinished.Length : isFinished.Position);
}
_state = CocoJumperState.Inactive;
RaiseExitEvent();
@@ -230,6 +250,7 @@ private void RaiseSearchResultChangedEventWithFilter()
{
EventHelper.EventHelperInstance.RaiseEvent(new SearchResultEvent
{
+ IsHighlightDisabled = IsHighlightDisabled(),
SearchEvents = _searchResults
.Where(x => x.Key.StartsWith(_choosingString))
.Select(p => new SearchEvent
@@ -246,7 +267,7 @@ private void SearchCurrentView()
{
int totalCount = 0;
if (_state != CocoJumperState.Searching)
- throw new Exception($"{nameof(SearchCurrentView)} - wrong state");
+ throw new InvalidStateException($"{nameof(SearchCurrentView)} - wrong state");
_searchResults.Clear();
if (string.IsNullOrEmpty(_searchString))
diff --git a/CocoJumper/Properties/AssemblyInfo.cs b/CocoJumper/Properties/AssemblyInfo.cs
index 8719ea2..f83a652 100644
--- a/CocoJumper/Properties/AssemblyInfo.cs
+++ b/CocoJumper/Properties/AssemblyInfo.cs
@@ -29,5 +29,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.2.0")]
-[assembly: AssemblyFileVersion("1.0.2.0")]
+[assembly: AssemblyVersion("1.0.3.0")]
+[assembly: AssemblyFileVersion("1.0.3.0")]
diff --git a/CocoJumper/source.extension.vsixmanifest b/CocoJumper/source.extension.vsixmanifest
index 3fc08e2..0f5b217 100644
--- a/CocoJumper/source.extension.vsixmanifest
+++ b/CocoJumper/source.extension.vsixmanifest
@@ -1,7 +1,7 @@
-
+
CocoJumper
Boost your productivity by easly jumping in code.