Skip to content

Commit 57cc2be

Browse files
author
Savas Ziplies
committed
Fixed: Bug evaluated file extensions with leading dot leading to issues
1 parent 0a814bb commit 57cc2be

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

MarkdownViewerPlusPlus/Forms/AbstractRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public virtual void Render(string text, string fileName = "")
138138
/// <param name="e"></param>
139139
protected void refreshToolStripMenuItem_Click(object sender, EventArgs e)
140140
{
141-
this.markdownViewer.UpdateMarkdownViewer();
141+
this.markdownViewer.Update();
142142
}
143143

144144
/// <summary>

MarkdownViewerPlusPlus/Forms/MarkdownViewerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ private void btnOptionsSave_Click(object sender, System.EventArgs e)
111111
//Fire the save event for all listeners
112112
this.SaveEvent(ref this.configuration.options);
113113
//Save to init
114-
this.configuration.Save();
114+
this.configuration.Save();
115115
//Close the options dialog when all has been done
116116
this.Close();
117117
}

MarkdownViewerPlusPlus/MarkdownViewer.cs

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ public void OnNotification(ScNotification notification)
122122
//Update the scintilla handle in all cases to keep track of which instance is active
123123
UpdateEditorInformation();
124124
this.Editor.CurrentBufferID = notification.Header.IdFrom;
125-
this.updateRenderer = true;
126-
Update(true);
125+
Update(true, true);
127126
}
128127
else if (notification.Header.Code == (uint)SciMsg.SCN_MODIFIED && !this.updateRenderer)
129128
{
@@ -140,12 +139,14 @@ public void OnNotification(ScNotification notification)
140139
///
141140
/// </summary>
142141
/// <param name="updateScrollBar"></param>
143-
protected void Update(bool updateScrollBar = false)
142+
/// <param name="updateRenderer"></param>
143+
public void Update(bool updateScrollBar = false, bool updateRenderer = false)
144144
{
145145
//Validate that the current file may be rendered
146146
if (this.configuration.ValidateFileExtension(this.currentFileExtension, this.currentFileName))
147147
{
148148
//Update the view
149+
this.updateRenderer = updateRenderer ? updateRenderer : this.updateRenderer;
149150
UpdateMarkdownViewer();
150151
//Update the scroll bar of the Viewer Panel only in case of vertical scrolls
151152
if (this.configuration.options.synchronizeScrolling && updateScrollBar)
@@ -158,7 +159,7 @@ protected void Update(bool updateScrollBar = false)
158159
this.renderer.Render($@"<p>
159160
Your configuration settings do not include the currently selected file extension.<br />
160161
The rendered file extensions are <b>'{this.configuration.options.fileExtensions}'</b>.<br />
161-
The current file is <i>'{this.currentFileName}'</i>. {this.Editor.GetModify()}
162+
The current file is <i>'{this.currentFileName}'</i>.
162163
</p>");
163164
}
164165
}
@@ -203,6 +204,8 @@ private void OptionsCommand()
203204
{
204205
options.ShowDialog(Control.FromHandle(PluginBase.GetCurrentScintilla()));
205206
}
207+
//Update after something potentially changed in the settings dialog
208+
Update(true, true);
206209
}
207210

208211
/// <summary>
@@ -251,8 +254,7 @@ public void MarkdownViewerCommand()
251254
if (!this.renderer.Visible)
252255
{
253256
UpdateEditorInformation();
254-
this.updateRenderer = true;
255-
Update(true);
257+
Update(true, true);
256258
}
257259
ToggleToolbarIcon(!this.renderer.Visible);
258260
}
@@ -265,6 +267,7 @@ protected void UpdateEditorInformation()
265267
this.Editor.SetScintillaHandle(PluginBase.GetCurrentScintilla());
266268
this.currentFileName = this.Notepad.GetCurrentFileName();
267269
this.currentFileExtension = Path.GetExtension(this.currentFileName);
270+
this.currentFileExtension = this.currentFileExtension.StartsWith(".") ? this.currentFileExtension.Substring(1, this.currentFileExtension.Length-1) : this.currentFileExtension;
268271
}
269272

270273
/// <summary>
@@ -286,7 +289,7 @@ public void ToggleToolbarIcon(bool show = true)
286289
/// <summary>
287290
///
288291
/// </summary>
289-
public void UpdateMarkdownViewer()
292+
protected void UpdateMarkdownViewer()
290293
{
291294
try
292295
{

MarkdownViewerPlusPlus/MarkdownViewerConfiguration.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,8 @@ public bool ValidateFileExtension(string fileExtension, string fileName = "")
172172
if (this.options.fileExtensions == null || this.options.fileExtensions == "") return true;
173173
//Something set but nothing given, check for "new " files (dirty dirty ^^)
174174
if (fileExtension == null || fileExtension == "") return this.options.inclNewFiles && fileName.StartsWith("new ");
175-
//Otherwise check
176-
return this.options.fileExtensions.Contains(fileExtension);
175+
//Otherwise check
176+
return this.options.fileExtensions.ToLower().Contains(fileExtension.ToLower());
177177
}
178178

179179
/// <summary>

MarkdownViewerPlusPlus/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("0.5.0.*")]
36-
[assembly: AssemblyFileVersion("0.5.0.0")]
35+
[assembly: AssemblyVersion("0.5.1.*")]
36+
[assembly: AssemblyFileVersion("0.5.1.0")]

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ A Notepad++ Plugin to view a Markdown file rendered on-the-fly
1919
* BugFixes ^^'
2020

2121
## Latest Versions
22+
* 0.5.1
23+
* Fixed a bug always returning false while checking file extensions
2224
* 0.5.0
2325
* Added an options dialog for file extensions, HTML CSS and PDF attributes
2426
* 0.4.5
2527
* Fixed handling rendering Markdown in either editor view (thanks to dail8859)
26-
* 0.4.4
27-
* Update renderer scrolling when caret causes a scroll event (thanks to dail8859)
2828

2929
Download the latest [release here][9]. For a full version history go [here][10].
3030

0 commit comments

Comments
 (0)