Skip to content

Commit 26a4728

Browse files
authored
Fix html/cshtml null reference (#168)
Fixes
1 parent b125350 commit 26a4728

6 files changed

Lines changed: 27 additions & 6 deletions

File tree

CodeiumVS/CodeLensConnection/CodeLensListener.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ namespace CodeiumVS
2424
[ContentType("vbscript")]
2525
[ContentType("TypeScript")]
2626
[ContentType("JavaScript")]
27+
[ContentType("html")]
28+
[ContentType("HTMLX")]
29+
[ContentType("Razor")]
2730
public class CodeLensListener : ICodeLensCallbackListener, ICodeLensListener
2831
{
2932

CodeiumVS/InlineDiff/InlineDiffAdornment.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,9 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv
760760
[Export(typeof(ILineTransformSourceProvider))]
761761
[Name("CodeiumInlineDiffViewProvider")]
762762
[ContentType("code")]
763+
[ContentType("html")]
764+
[ContentType("HTMLX")]
765+
[ContentType("Razor")]
763766
[TextViewRole(PredefinedTextViewRoles.Document)]
764767
internal class CodeiumInlineDiffViewProvider : ILineTransformSourceProvider
765768
{

CodeiumVS/SuggestionUI/SuggestionTagger.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,9 @@ void AddInsertionTextBlock(int start, int end, string line)
267267
{
268268
string remainder = line.Substring(start, end - start);
269269
var textBlock = CreateTextBox(remainder, greyBrush);
270-
GetTagger().UpdateAdornment(textBlock);
270+
var inlineTagger = GetTagger();
271+
if (inlineTagger == null) { return; }
272+
inlineTagger.UpdateAdornment(textBlock);
271273
}
272274
catch (ArgumentOutOfRangeException)
273275
{
@@ -281,7 +283,9 @@ public void UpdateAdornment(IWpfTextView view, string userText, int suggestionSt
281283
try
282284
{
283285
stackPanel.Children.Clear();
284-
GetTagger().ClearAdornment();
286+
var inlineTagger = GetTagger();
287+
if (inlineTagger == null) { return; }
288+
inlineTagger.ClearAdornment();
285289
for (int i = suggestionStart; i < suggestion.Item2.Length; i++)
286290
{
287291
string line = suggestion.Item2[i];
@@ -363,6 +367,7 @@ private void OnSizeChanged(object sender, EventArgs e)
363367
var start = view.TextViewLines.GetCharacterBounds(snapshotLine.Start);
364368

365369
InlineGreyTextTagger inlineTagger = GetTagger();
370+
if (inlineTagger == null) { return; }
366371
inlineTagger.FormatText(GetTextFormat());
367372

368373
if (stackPanel.Children.Count > 0)
@@ -516,6 +521,7 @@ public void ClearSuggestion()
516521
{
517522
if (!showSuggestion) return;
518523
InlineGreyTextTagger inlineTagger = GetTagger();
524+
if (inlineTagger == null) { return; }
519525
inlineTagger.ClearAdornment();
520526
inlineTagger.MarkDirty();
521527
suggestion = null;
@@ -536,7 +542,9 @@ void MarkDirty()
536542
{
537543
try
538544
{
539-
GetTagger().MarkDirty();
545+
InlineGreyTextTagger inlineTagger = GetTagger();
546+
if (inlineTagger == null) { return; }
547+
inlineTagger.MarkDirty();
540548
ITextSnapshot newSnapshot = buffer.CurrentSnapshot;
541549
this.snapshot = newSnapshot;
542550

CodeiumVS/SuggestionUI/TextViewListener.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,7 @@ public async void ShowNextSuggestion()
399399
currentCompletionID = suggestions[suggestionIndex].Item2;
400400

401401
SuggestionTagger tagger = GetTagger();
402+
if (tagger == null) { return; }
402403

403404
int lineN, characterN;
404405
int res = _textViewAdapter.GetCaretPos(out lineN, out characterN);
@@ -432,10 +433,9 @@ public async void ShowNextSuggestion()
432433
public bool CompleteSuggestion(bool checkLine = true)
433434
{
434435
var tagger = GetTagger();
435-
bool onSameLine = tagger.OnSameLine();
436436
if (tagger != null)
437437
{
438-
if (tagger.IsSuggestionActive() && (onSameLine || !checkLine) && tagger.CompleteText())
438+
if (tagger.IsSuggestionActive() && (tagger.OnSameLine() || !checkLine) && tagger.CompleteText())
439439
{
440440
ClearCompletionSessions();
441441
OnSuggestionAccepted(currentCompletionID);
@@ -535,6 +535,7 @@ public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pv
535535
if (bindings == null || bindings.Length <= 0)
536536
{
537537
var tagger = GetTagger();
538+
if (tagger == null) { return m_nextCommandHandler.Exec(ref pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut); }
538539

539540
ICompletionSession session = m_provider.CompletionBroker.GetSessions(_view).FirstOrDefault();
540541
if (session != null && session.SelectedCompletionSet != null)
@@ -636,6 +637,9 @@ public void Dispose()
636637
[Export(typeof(IVsTextViewCreationListener))]
637638
[Name("TextViewListener")]
638639
[ContentType("code")]
640+
[ContentType("html")]
641+
[ContentType("HTMLX")]
642+
[ContentType("Razor")]
639643
[TextViewRole(PredefinedTextViewRoles.Document)]
640644

641645
internal class TextViewListener : IVsTextViewCreationListener

CodeiumVS/Utilities/TextHighlighter.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ public HighlightWordFormatDefinition()
9797

9898
[Export(typeof(IViewTaggerProvider))]
9999
[ContentType("code")]
100+
[ContentType("html")]
101+
[ContentType("HTMLX")]
102+
[ContentType("Razor")]
100103
[TagType(typeof(HighlightWordTag))]
101104
internal class HighlightWordTaggerProvider : IViewTaggerProvider
102105
{

CodeiumVS/source.extension.vsixmanifest

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
33
<Metadata>
4-
<Identity Id="Codeium.VisualStudio" Version="1.9.12" Language="en-US" Publisher="Codeium" />
4+
<Identity Id="Codeium.VisualStudio" Version="1.9.13" Language="en-US" Publisher="Codeium" />
55
<DisplayName>Codeium</DisplayName>
66
<Description xml:space="preserve">The modern coding superpower: free AI code acceleration plugin for your favorite languages. Type less. Code more. Ship faster.</Description>
77
<MoreInfo>https://www.codeium.com</MoreInfo>

0 commit comments

Comments
 (0)