diff --git a/README.md b/README.md index 29b304b..02589f1 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file +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) \ No newline at end of file diff --git a/art/formatting.png b/art/formatting.png new file mode 100644 index 0000000..d48b5fd Binary files /dev/null and b/art/formatting.png differ diff --git a/src/BaseClasses/TokenErrorTaggerBase.cs b/src/BaseClasses/TokenErrorTaggerBase.cs index a1dc716..810b775 100644 --- a/src/BaseClasses/TokenErrorTaggerBase.cs +++ b/src/BaseClasses/TokenErrorTaggerBase.cs @@ -38,11 +38,6 @@ public override IEnumerable> GetTags(IMappingTagSpan(span, errorTag); } - - if (IsFullParse) - { - - } } } } diff --git a/src/BaseClasses/TokenTaggerConsumerBase.cs b/src/BaseClasses/TokenTaggerConsumerBase.cs index e5fcce0..fdba5fb 100644 --- a/src/BaseClasses/TokenTaggerConsumerBase.cs +++ b/src/BaseClasses/TokenTaggerConsumerBase.cs @@ -10,8 +10,6 @@ public abstract class TokenTaggerConsumerBase : ITagger, IDisposable private readonly ITagAggregator _tags; private bool _isDisposed; - public bool IsFullParse { get; private set; } - public TokenTaggerConsumerBase(ITagAggregator tags) { _tags = tags; @@ -20,12 +18,10 @@ public TokenTaggerConsumerBase(ITagAggregator 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> GetTags(NormalizedSnapshotSpanCollection spans) diff --git a/src/Language/EditorFeatures.cs b/src/Language/EditorFeatures.cs index dc653ca..a89c3ac 100644 --- a/src/Language/EditorFeatures.cs +++ b/src/Language/EditorFeatures.cs @@ -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 ClassificationMap { get; } = new() @@ -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 { } @@ -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 CommitChars => new char[] { ' ', '\'', '"', ',', '.', ';', ':', '\\', '$' }; @@ -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. diff --git a/src/Language/IntelliSense.cs b/src/Language/IntelliSense.cs index 4aaf09b..77f1f89 100644 --- a/src/Language/IntelliSense.cs +++ b/src/Language/IntelliSense.cs @@ -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); + } } } diff --git a/vs-publish.json b/vs-publish.json index 30d2a73..e148b2b 100644 --- a/vs-publish.json +++ b/vs-publish.json @@ -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"