Skip to content

Commit

Permalink
Fix crash on swiching complete match on emtpy result.
Browse files Browse the repository at this point in the history
  • Loading branch information
nex3z committed Jul 8, 2016
1 parent ae16829 commit 90781ad
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion NppLogGazer/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Main
{
#region " Fields "
internal const string PluginName = "NppLogGazer";
public const string PluginVersion = "0.8.1";
public const string PluginVersion = "0.8.2";
static string iniFilePath = null;
static string defaultKeywordListFile = null;
static string defaultPatternListFile = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace NppLogGazer.PatternTracer.Presenter
{
Expand Down Expand Up @@ -231,7 +229,7 @@ private void ShowResult(List<ResultModel> result, PatternModel pattern)
{
IResultView resultFrm = new FrmResult();
SearchResultPresenter resultPresenter = new SearchResultPresenter(resultFrm);
resultPresenter.RenderResult(result, pattern.PatternText.Count);
resultPresenter.RenderResult(result, pattern);
}
}
}
19 changes: 12 additions & 7 deletions NppLogGazer/PatternTracer/Presenter/SearchResultPresenter.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using NppLogGazer.PatternTracer.Model;
using NppLogGazer.PatternExtractor.Model;
using NppLogGazer.PatternTracer.Model;
using NppLogGazer.PatternTracer.View;
using NppLogGazer.PatternTracer.View.Event;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NppLogGazer.PatternTracer.Presenter
Expand All @@ -12,6 +12,7 @@ class SearchResultPresenter
{
private IResultView view;
private List<ResultModel> result;
private PatternModel pattern;

public SearchResultPresenter(IResultView resultView)
{
Expand All @@ -26,20 +27,24 @@ private void WireUpEvents()

private void ResultFilterChanged(Object sender, ResultFilterChangedEventArgs args)
{
string resultText = FormatResult(result, args.CompleteMatch ? result[0].KeywordCount : 0);
view.ShowResult(resultText);
if (pattern != null && result != null)
{
string resultText = FormatResult(result, args.CompleteMatch ? pattern.PatternText.Count : 0);
view.ShowResult(resultText);
}
}

public void RenderResult(List<ResultModel> resultList, int matchCountThreshold)
public void RenderResult(List<ResultModel> resultList, PatternModel pattern)
{
result = resultList;
string resultText = FormatResult(resultList, matchCountThreshold);
this.pattern = pattern;
string resultText = FormatResult(resultList, pattern.PatternText.Count);
view.ShowResult(resultText);
}

private string FormatResult(List<ResultModel> resultList, int matchCountThreshold)
{
if (resultList.Count == 0)
if (resultList == null || resultList.Count == 0)
{
return Properties.Resources.pattern_tracer_status_not_found;
}
Expand Down

0 comments on commit 90781ad

Please sign in to comment.