<p dir="ltr">If nothing is selected, clang-format should format the current line.. At least that's the intended behavior. Doesn't it do that? </p>
<div class="gmail_quote">On Aug 27, 2015 3:21 PM, "Beren Minor" <<a href="mailto:beren.minor%2Bgithub@gmail.com">beren.minor+github@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">berenm created this revision.<br>
berenm added a reviewer: djasper.<br>
berenm added a subscriber: cfe-commits.<br>
<br>
By default, clang-format VS plugin only reformats the selected code.<br>
<br>
To reformat the whole document, the user has to select everything before calling the reformat shortcut.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D12405" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12405</a><br>
<br>
Files:<br>
tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs<br>
<br>
Index: tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs<br>
===================================================================<br>
--- tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs<br>
+++ tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs<br>
@@ -84,8 +84,13 @@<br>
// We're not in a text view.<br>
return;<br>
string text = view.TextBuffer.CurrentSnapshot.GetText();<br>
- int start = view.Selection.Start.Position.GetContainingLine().Start.Position;<br>
- int end = view.Selection.End.Position.GetContainingLine().End.Position;<br>
+ int start = 0;<br>
+ int end = text.Length;<br>
+ if (!view.Selection.IsEmpty)<br>
+ {<br>
+ start = view.Selection.Start.Position.GetContainingLine().Start.Position;<br>
+ end = view.Selection.End.Position.GetContainingLine().End.Position;<br>
+ }<br>
int length = end - start;<br>
// clang-format doesn't support formatting a range that starts at the end<br>
// of the file.<br>
<br>
<br>
</blockquote></div>