[PATCH] D12405: [clang-format-vs] Format the whole document if nothing is selected
Beren Minor via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 27 06:21:04 PDT 2015
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12405.33317.patch
Type: text/x-patch
Size: 1054 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150827/3c0bd3c7/attachment.bin>
More information about the cfe-commits
mailing list