Skip to content

Commit b4820e2

Browse files
committed
Code: Analysis fixes.
1 parent 515949d commit b4820e2

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

EditorExtensions/Markdown/Margin/MarkdownMargin.cs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@
44
using System.Text;
55
using System.Windows;
66
using System.Windows.Controls;
7-
using MadsKristensen.EditorExtensions.Margin;
87
using MadsKristensen.EditorExtensions.Settings;
98
using Microsoft.VisualStudio.Text;
10-
using Microsoft.VisualStudio.Text.Editor;
119
using mshtml;
1210

1311
namespace MadsKristensen.EditorExtensions.Markdown
@@ -17,9 +15,9 @@ internal class MarkdownMargin : CompilingMarginBase
1715
private HTMLDocument _document;
1816
private WebBrowser _browser;
1917
private const string _stylesheet = "WE-Markdown.css";
20-
private float _cachedPosition = 0,
21-
_cachedHeight = 0,
22-
_positionPercentage = 0;
18+
private double _cachedPosition = 0,
19+
_cachedHeight = 0,
20+
_positionPercentage = 0;
2321

2422
public MarkdownMargin(ITextDocument document)
2523
: base(WESettings.Instance.Markdown, document)
@@ -76,7 +74,7 @@ protected override void UpdateMargin(CompilerResult result)
7674
}
7775

7876
_cachedPosition = _document.documentElement.getAttribute("scrollTop");
79-
_cachedHeight = _document.body.offsetHeight;
77+
_cachedHeight = Math.Max(1.0, _document.body.offsetHeight);
8078
_positionPercentage = _cachedPosition * 100 / _cachedHeight;
8179

8280
_browser.NavigateToString(html);
@@ -89,7 +87,6 @@ protected override FrameworkElement CreatePreviewControl()
8987
_browser.Navigated += (s, e) =>
9088
{
9189
_document = _browser.Document as HTMLDocument;
92-
_cachedPosition = _document.documentElement.getAttribute("scrollTop");
9390
_cachedHeight = _document.body.offsetHeight;
9491
_document.documentElement.setAttribute("scrollTop", _positionPercentage * _cachedHeight / 100);
9592
};

EditorExtensions/TypeScript/Compilers/TypeScriptCompilationNotifier.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ private string GetOutputFileName()
3333
Project project = ProjectHelpers.GetProject(SourceFilePath);
3434
IVsHierarchy hierarchy = null;
3535

36-
if (project != null)
37-
solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy);
36+
if (project != null && solution.GetProjectOfUniqueName(project.UniqueName, out hierarchy) != VSConstants.S_OK)
37+
return string.Empty;
3838

3939
IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage;
4040

0 commit comments

Comments
 (0)