I see.. I think we'll want to keep the current behavior there.. On Aug 27, 2015 3:38 PM, "Beren Minor" <beren.minor+git...@gmail.com> wrote:
> Alright, my bad. It does indeed. > > I was trying to add a "Reformat all on save" feature in the plugin, and > after struggling with VSSDK I thought this would be an easy first step. > > -- > Beren Minor > > On Thu, Aug 27, 2015 at 3:36 PM, Aaron Ballman <aa...@aaronballman.com> > wrote: > >> On Thu, Aug 27, 2015 at 9:34 AM, Daniel Jasper via cfe-commits >> <cfe-commits@lists.llvm.org> wrote: >> > If nothing is selected, clang-format should format the current line.. At >> > least that's the intended behavior. Doesn't it do that? >> >> It currently reformats the current line (possibly extended if the >> expression spans multiple lines) for me. >> >> ~Aaron >> >> > >> > On Aug 27, 2015 3:21 PM, "Beren Minor" <beren.minor+git...@gmail.com> >> wrote: >> >> >> >> berenm created this revision. >> >> berenm added a reviewer: djasper. >> >> berenm added a subscriber: cfe-commits. >> >> >> >> By default, clang-format VS plugin only reformats the selected code. >> >> >> >> To reformat the whole document, the user has to select everything >> before >> >> calling the reformat shortcut. >> >> >> >> >> >> http://reviews.llvm.org/D12405 >> >> >> >> Files: >> >> tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs >> >> >> >> Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs >> >> =================================================================== >> >> --- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs >> >> +++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs >> >> @@ -84,8 +84,13 @@ >> >> // We're not in a text view. >> >> return; >> >> string text = view.TextBuffer.CurrentSnapshot.GetText(); >> >> - int start = >> >> view.Selection.Start.Position.GetContainingLine().Start.Position; >> >> - int end = >> >> view.Selection.End.Position.GetContainingLine().End.Position; >> >> + int start = 0; >> >> + int end = text.Length; >> >> + if (!view.Selection.IsEmpty) >> >> + { >> >> + start = >> >> view.Selection.Start.Position.GetContainingLine().Start.Position; >> >> + end = >> >> view.Selection.End.Position.GetContainingLine().End.Position; >> >> + } >> >> int length = end - start; >> >> // clang-format doesn't support formatting a range that >> >> starts at the end >> >> // of the file. >> >> >> >> >> > >> > _______________________________________________ >> > cfe-commits mailing list >> > cfe-commits@lists.llvm.org >> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >> > >> > >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits