<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p style="margin-top:0;margin-bottom:0">Disabling lines collapsing was the simplest thing to do since I'm not deep in libFormat code :)</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">And after all it's possible to handle only one range from r<span style="font-family: Calibri, Helvetica, sans-serif, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">eformat()
 return if </span>you need. So it does not really matter what happens with the code outside of it.</p>
<p style="margin-top:0;margin-bottom:0"><br>
</p>
<p style="margin-top:0;margin-bottom:0">And I will be glad if somebody with better code understanding implements it better and makes some kind of auto insertion of token inside libFormat.</p>
</div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Sam McCall <sammccall@google.com><br>
<b>Sent:</b> Friday, October 12, 2018 9:36:13 AM<br>
<b>To:</b> Ivan Donchevskii<br>
<b>Cc:</b> clang developer list<br>
<b>Subject:</b> Re: [cfe-dev] [clang-format] Trying to use libFormat for code indentation</font>
<div> </div>
</div>
<meta content="text/html; charset=utf-8">
<div>
<div dir="ltr">Cool! We were just chatting over breakfast about inserting a token to preserve the whitespace :-)
<div>Does this work well in practice with unmatched parens/braces?</div>
<div><br>
</div>
<div>Like when typing:</div>
<div>void foo() {</div>
<div>  auto Lambda = [&](int bar) {</div>
<div>     ^</div>
<div>
<div><br>
</div>
<div>The idea that you disable *all* line collapsing seems like a big hammer, is it possible to set a property on the dummy token that forces a wrap before it?</div>
<div><br>
</div>
<div>I do wonder whether that makes sense as a top-level option, or whether libFormat should grow an API to format-while-typing around the cursor: would take care of inserting/removing the token, setting options about collapsing lines etc.</div>
</div>
<div><br>
</div>
<div>Happy to take this discussion to the code review.</div>
</div>
<br>
<div class="x_gmail_quote">
<div dir="ltr">On Fri, Oct 12, 2018 at 9:15 AM Ivan Donchevskii <<a href="mailto:ivan.donchevskii@qt.io">ivan.donchevskii@qt.io</a>> wrote:<br>
</div>
<blockquote class="x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-636350619840711225divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p style="margin-top:0; margin-bottom:0">Hi!</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">I've decided not to wait but to try something myself :)</p>
<p style="margin-top:0; margin-bottom:0">Check this out - <a href="https://reviews.llvm.org/D53072" class="x_m_-636350619840711225OWAAutoLink" id="x_m_-636350619840711225LPlnk446522" target="_blank">https://reviews.llvm.org/D53072</a></p>
<p style="margin-top:0; margin-bottom:0">This fixes some problems for me and I only need to add some string to the new empty line not to have indentation removed.</p>
<p style="margin-top:0; margin-bottom:0"><br>
</p>
<p style="margin-top:0; margin-bottom:0">Kind regards,</p>
<p style="margin-top:0; margin-bottom:0">Ivan</p>
</div>
<hr style="display:inline-block; width:98%">
<div id="x_m_-636350619840711225divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Sam McCall <<a href="mailto:sammccall@google.com" target="_blank">sammccall@google.com</a>><br>
<b>Sent:</b> Friday, October 12, 2018 9:04:24 AM<br>
<b>To:</b> Ivan Donchevskii<br>
<b>Cc:</b> clang developer list<br>
<b>Subject:</b> Re: [cfe-dev] [clang-format] Trying to use libFormat for code indentation</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">Hi Ivan,
<div>We're also interested in as-you-type formatting like indentation for clangd.</div>
<div>(<a href="http://lists.llvm.org/pipermail/clangd-dev/2018-September/000102.html" target="_blank">http://lists.llvm.org/pipermail/clangd-dev/2018-September/000102.html</a>)</div>
<div>But I don't think anyone's deeply explored what would be needed from libFormat to allow this.</div>
<div>Cheers, Sam</div>
</div>
</div>
<br>
<div class="x_m_-636350619840711225x_gmail_quote">
<div dir="ltr">On Fri, Oct 5, 2018 at 1:31 PM Ivan Donchevskii via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>> wrote:<br>
</div>
<blockquote class="x_m_-636350619840711225x_gmail_quote" style="margin:0 0 0 .8ex; border-left:1px #ccc solid; padding-left:1ex">
<div dir="ltr">
<div id="x_m_-636350619840711225x_m_-6564862283369422425divtagdefaultwrapper" dir="ltr">
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
Hi,</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<br>
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
libFormat and clang-format are great for formatting but I want to use libFormat a bit differently - to provide the indentation for the next line (inside IDE, when you press CR in code editor).</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<br>
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
Probably I miss some handy flag which helps with that but so far I've found only workarounds to do what I need:</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"> - add some stupid expression to the new line<span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px"> (something
 like "</span><span style="font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:16px">a;")</span> to force libFormat indent it</span><br>
</p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"> - play with clang-format flags to prevent it from shrinking the new line into the previous one</span></p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"> - set ColumnLimit to the length of the previous line also to prevent shrinking</span></p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"><br>
</span></p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt">All of them work completely unreliably. Also it's often some incomplete code in the middle of typing so it might have unfinished expressions.</span></p>
<p style="color:rgb(0,0,0); font-family:Calibri,Helvetica,sans-serif,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols; font-size:12pt; margin-top:0px; margin-bottom:0px">
<span style="font-size:12pt"><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">So I want to ask if somebody has/had similar
</span>use cases<span style="font-size:12pt"> and knows how to deal with them before adding some special flag to clang-format and trying to solve my issues there.</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt"><br>
</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">Kind regards,</span></p>
<p style="margin-top:0px; margin-bottom:0px"><span style="font-size:12pt">Ivan</span></p>
</div>
</div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</body>
</html>