Skip to content

Commit 9f4c60e

Browse files
author
SlavaRa
committed
Stable
1 parent e449fcc commit 9f4c60e

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

PostfixCodeCompletion/Helpers/TemplateUtils.cs

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,7 @@ static class TemplateUtils
4040
PATTERN_NUMBER,
4141
PATTERN_STRING
4242
};
43-
44-
internal static bool IsValidFileForCompletion(string fileName)
45-
{
46-
var language = string.Empty;
47-
var ext = Path.GetExtension(fileName).TrimStart('.');
48-
foreach (var it in PluginBase.MainForm.SciConfig.AllLanguages)
49-
{
50-
var extensions = it.fileextensions.Split(Convert.ToChar(","));
51-
if (!extensions.Contains(ext)) continue;
52-
language = it.name;
53-
break;
54-
}
55-
return language.Length > 0 && GetHasTemplates(language);
56-
}
57-
43+
5844
internal static bool GetHasTemplates()
5945
{
6046
return GetHasTemplates(PluginBase.MainForm.CurrentDocument.SciControl.ConfigurationLanguage.ToLower());

PostfixCodeCompletion/PluginMain.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ static void UpdateCompletionList(MemberModel target, ASResult expr)
197197
static ASResult GetPostfixCompletionExpr()
198198
{
199199
var doc = PluginBase.MainForm.CurrentDocument;
200-
if (!TemplateUtils.IsValidFileForCompletion(doc.FileName)) return null;
200+
if (doc == null || !doc.IsEditable) return null;
201+
var language = PluginBase.CurrentProject.Language;
202+
if (!ASContext.GetLanguageContext(language).IsFileValid || !TemplateUtils.GetHasTemplates(language)) return null;
201203
var sci = doc.SciControl;
202204
var currentLine = sci.CurrentLine;
203205
var positionFromLine = sci.PositionFromLine(currentLine);

0 commit comments

Comments
 (0)