Skip to content

Commit

Permalink
Improvements to IntelliSense
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
madskristensen committed Dec 27, 2021
1 parent dbb4203 commit 5ee94b8
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ Collapse sections for better overview of the document.

![Outlining](art/outlining.png)

Notice how only comments starting with a semicolon is correctly identified as a comment.
Notice how only comments starting with a semicolon is correctly identified as a comment.

## Formatting
You can format the whole document `Ctrl+K,Ctrl+D` or the current selection `Ctrl+K,Ctrl+F`. It will add a line break between registry key entries, trim whitespace, and other clean-up formatting.

![Formatting](art/formatting.png)
Binary file added art/formatting.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions src/BaseClasses/TokenErrorTaggerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,6 @@ public override IEnumerable<ITagSpan<IErrorTag>> GetTags(IMappingTagSpan<TokenTa
{
yield return new TagSpan<IErrorTag>(span, errorTag);
}

if (IsFullParse)
{

}
}
}
}
6 changes: 1 addition & 5 deletions src/BaseClasses/TokenTaggerConsumerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ public abstract class TokenTaggerConsumerBase<TTag> : ITagger<TTag>, IDisposable
private readonly ITagAggregator<TokenTag> _tags;
private bool _isDisposed;

public bool IsFullParse { get; private set; }

public TokenTaggerConsumerBase(ITagAggregator<TokenTag> tags)
{
_tags = tags;
Expand All @@ -20,12 +18,10 @@ public TokenTaggerConsumerBase(ITagAggregator<TokenTag> tags)

private void TokenTagsChanged(object sender, TagsChangedEventArgs e)
{
ITextBuffer buffer = e.Span.AnchorBuffer;
ITextBuffer buffer = e.Span.BufferGraph.TopBuffer;
SnapshotSpan span = new(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length);

IsFullParse = true;
TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(span));
IsFullParse = false;
}

public IEnumerable<ITagSpan<TTag>> GetTags(NormalizedSnapshotSpanCollection spans)
Expand Down
8 changes: 0 additions & 8 deletions src/Language/EditorFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ namespace PkgdefLanguage
[Export(typeof(ITaggerProvider))]
[TagType(typeof(IClassificationTag))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
public class SyntaxHighligting : TokenClassificationTaggerBase
{
public override Dictionary<object, string> ClassificationMap { get; } = new()
Expand All @@ -31,27 +30,23 @@ public class SyntaxHighligting : TokenClassificationTaggerBase
[Export(typeof(ITaggerProvider))]
[TagType(typeof(IStructureTag))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
public class Outlining : TokenOutliningTaggerBase
{ }

[Export(typeof(ITaggerProvider))]
[TagType(typeof(IErrorTag))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
public class ErrorSquigglies : TokenErrorTaggerBase
{ }

[Export(typeof(IWpfTextViewCreationListener))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
[TextViewRole(PredefinedTextViewRoles.PrimaryDocument)]
internal sealed class ErrorList : TokenErrorListBase
{ }

[Export(typeof(IAsyncQuickInfoSourceProvider))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
internal sealed class Tooltips : TokenQuickInfoBase
{ }

Expand All @@ -62,14 +57,12 @@ internal sealed class Tooltips : TokenQuickInfoBase
[BracePair('"', '"')]
[BracePair('$', '$')]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
[ProvideBraceCompletion(Constants.LanguageName)]
internal sealed class BraceCompletion : BraceCompletionBase
{ }

[Export(typeof(IAsyncCompletionCommitManagerProvider))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
internal sealed class CompletionCommitManager : CompletionCommitManagerBase
{
public override IEnumerable<char> CommitChars => new char[] { ' ', '\'', '"', ',', '.', ';', ':', '\\', '$' };
Expand All @@ -78,7 +71,6 @@ internal sealed class CompletionCommitManager : CompletionCommitManagerBase
[Export(typeof(IViewTaggerProvider))]
[TagType(typeof(TextMarkerTag))]
[ContentType(Constants.LanguageName)]
[Name(Constants.LanguageName)]
internal sealed class BraceMatchingTaggerProvider : BraceMatchingBase
{
// This will match parenthesis, curly brackets, and square brackets by default.
Expand Down
13 changes: 9 additions & 4 deletions src/Language/IntelliSense.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,18 @@ public CompletionStartData InitializeCompletion(CompletionTrigger trigger, Snaps
var column = triggerLocation.Position - item.Span.Start;
var start = item.Text.LastIndexOf('\\', column - 1) + 1;
var end = item.Text.IndexOf('\\', column);
end = end >= start ? end : item.Text.IndexOf(']', column);
end = end >= start ? end : item.Text.TrimEnd().Length;
var close = item.Text.IndexOf(']', column);
var textEnd = item.Text.IndexOf(']', column);
end = end >= start ? end : close;
end = end >= start ? end : textEnd;

if (end >= start)
{
var span = new SnapshotSpan(triggerLocation.Snapshot, item.Span.Start + start, end - start);
return new CompletionStartData(CompletionParticipation.ProvidesItems, span);
if (close == -1 || column <= close)
{
var span = new SnapshotSpan(triggerLocation.Snapshot, item.Span.Start + start, end - start);
return new CompletionStartData(CompletionParticipation.ProvidesItems, span);
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions vs-publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
"pathOnDisk": "art/colorization.png",
"targetPath": "art/colorization.png"
},
{
"pathOnDisk": "art/formatting.png",
"targetPath": "art/formatting.png"
},
{
"pathOnDisk": "art/intellisense.gif",
"targetPath": "art/intellisense.gif"
Expand Down

0 comments on commit 5ee94b8

Please sign in to comment.