Skip to content

Commit a339d3c

Browse files
committed
Remove Encouragement from Immediate Window
Encouragement was using the presence of an ITextDocument as the predicate for whether or not a given ITextView is eligible for encouragement tips Having an ITextDocument means a given ITextView is backed by a physical file and saving such an item should be encouraged. The problem is windows like the 'Immediate Window' are backed by physical files (esp with Roslyn). These files are implementation details though and saving them has no benefit to the user. In these cases the save operation isn't even directly surfaced to the user. It happens as a consequence of a non-save like action (in the case of the 'Immediate Window', it happens on every key stroke). This causes Encouragement to be displayed at unexpected times This change fixes this problem by changing the predicate slightly. We now check for ITextDocument (has ITextView has a physical backing file) and the Document role (this ITextView is being displayed as a document).
1 parent c45e6e1 commit a339d3c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

EncouragePackage/EncourageIntellisenseControllerProvider.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ public IIntellisenseController TryCreateIntellisenseController(ITextView textVie
2828
return null;
2929
}
3030

31+
// In general having an ITextDocument is sufficient to determine if a given ITextView is
32+
// back by an actual document. There are some windows though, like the Immediate Window,
33+
// which aren't documents that do still have a backing temporary file. These files are
34+
// uninteresting to Encourage because they are temporary files that exist as an
35+
// implementation detail
36+
//
37+
// The easiest way to filter for real documents is to check for the Document role
38+
if (!textView.Roles.Contains(PredefinedTextViewRoles.Document))
39+
{
40+
return null;
41+
}
42+
3143
return new EncourageIntellisenseController(textView, textDocument, this);
3244
}
3345
}

0 commit comments

Comments
 (0)