<table><tr><td style="">dfaure requested changes to this revision.<br />dfaure added a comment.<br />This revision now requires changes to proceed.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D25572">View Revision</a></tr></table><br /><div><div><p>I think this needs more work, we lost some tolerance here, AFAICS.</p></div></div><br /><div><strong>INLINE COMMENTS</strong><div><div style="margin: 6px 0 12px 0;"><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25572#inline-144657">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfilewidget.cpp:1751</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">    <span class="bright"></span><span style="color: #aa4000"><span class="bright">const</span></span><span class="bright"> </span><span style="color: #aa4000"><span class="bright">int</span></span><span class="bright"> </span><span class="n"><span class="bright">count</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span class="n">line</span><span class="p">.</span><span class="n">co<span class="bright">unt</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QLatin1Char</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">'"'</span></span><span class="bright"></span><span class="p"><span class="bright">));</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">    <span style="color: #aa4000">if</span> <span class="p">(</span><span class="n">count</span> <span style="color: #aa2211">==</span> <span style="color: #601200">0</span><span class="p">)</span> <span class="p">{</span>   <span style="color: #74777d">// no " " -> assume one single file</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">    <span class="bright"></span><span style="color: #aa4000"><span class="bright">if</span></span><span class="bright"> </span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #aa2211"><span class="bright">!</span></span><span class="n">line</span><span class="p">.</span><span class="n">co<span class="bright">ntains</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QStringLiteral</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"</span></span><span class="bright"></span><span style="color: #bb6622"><span class="bright">\"</span></span><span class="bright"></span><span style="color: #766510"><span class="bright"> </span></span><span class="bright"></span><span style="color: #bb6622"><span class="bright">\"</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"</span></span><span class="bright"></span><span class="p"><span class="bright">)))</span></span><span class="bright"> </span><span class="p"><span class="bright">{</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; ">        <span style="color: #aa4000">if</span> <span class="p">(</span><span style="color: #aa2211">!</span><span class="n">QDir</span><span style="color: #aa2211">::</span><span class="n">isAbsolutePath</span><span class="p">(</span><span class="n">line</span><span class="p">))</span> <span class="p">{</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">What if I had <tt style="background: #ebebeb; font-size: 13px;">"file1.txt" "file2.txt"</tt> and I manually edit that to remove the second file, ending up with just <tt style="background: #ebebeb; font-size: 13px;">"file1.txt"</tt>? The double-quotes will no longer be removed, because of this modified condition.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25572#inline-144659">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfilewidget.cpp:1767</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; ">    <span style="color: #aa4000">while</span> <span class="p">(</span><span style="color: #304a96">true</span><span class="p">)</span> <span class="p">{</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">        <span class="n">index1</span> <span style="color: #aa2211">=</span> <span class="n">line</span><span class="p">.</span><span class="n">indexOf</span><span class="p">(</span><span class="n">Q<span class="bright">Latin1Char</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">'"'</span></span><span class="bright"></span><span class="p"><span class="bright">),</span></span><span class="bright"> </span><span class="n"><span class="bright">start</span></span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">        <span class="bright"></span><span class="n"><span class="bright">index2</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span class="n"><span class="bright">line</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">indexOf</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QLatin1Char</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">'"'</span></span><span class="bright"></span><span class="p"><span class="bright">),</span></span><span class="bright"> </span><span class="n"><span class="bright">index1</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">+</span></span><span class="bright"> </span><span style="color: #601200"><span class="bright">1</span></span><span class="bright"></span><span class="p"><span class="bright">);</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">index1</span> <span style="color: #aa2211">=</span> <span class="n">line</span><span class="p">.</span><span class="n">indexOf</span><span class="p">(</span><span class="n">Q<span class="bright">StringLiteral</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"</span></span><span class="bright"></span><span style="color: #bb6622"><span class="bright">\"</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">"</span></span><span class="bright"></span><span class="p"><span class="bright">),</span></span><span class="bright"> </span><span class="n"><span class="bright">index1</span></span><span class="p">);</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="bright"></span><span style="color: #74777d"><span class="bright">// find next word separator</span></span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Isn't there a <tt style="background: #ebebeb; font-size: 13px;">"</tt> at this position, always?<br />
Initially, at position 0, and then later, we know we hit <tt style="background: #ebebeb; font-size: 13px;">" "</tt> so <tt style="background: #ebebeb; font-size: 13px;">index1 = index2+2</tt> could be done at the end of the loop (instead of +1), and here we don't need an <tt style="background: #ebebeb; font-size: 13px;">indexOf</tt> call anymore.<br />
I assume this was done in order to be tolerant to things like two spaces or something, but now the separator is hardcoded to <tt style="background: #ebebeb; font-size: 13px;">" "</tt> so we *know* there's a quote at <tt style="background: #ebebeb; font-size: 13px;">index2</tt>+2 after finding a quote at <tt style="background: #ebebeb; font-size: 13px;">index2</tt>.</p>

<p style="padding: 0; margin: 8px;">Well, I guess we can keep an initial indexOf (outside the loop) in case there's a leading space (because a user manually removed the first file).</p>

<p style="padding: 0; margin: 8px;">So this needs additional unittests for leading space, trailing space, single-quoted-file .... and I wonder if we are OK with no longer supporting two spaces (e.g. because the user manually removed some intermediate file in the list).</p>

<p style="padding: 0; margin: 8px;">The separator is in fact <tt style="background: #ebebeb; font-size: 13px;">" +"</tt> in regexp syntax, then?</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25572#inline-144656">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfilewidget.cpp:1769</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(251, 175, 175, .7);">        <span class="bright"></span><span class="n"><span class="bright">index2</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">=</span></span><span class="bright"> </span><span class="n"><span class="bright">line</span></span><span class="bright"></span><span class="p"><span class="bright">.</span></span><span class="bright"></span><span class="n"><span class="bright">indexOf</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span class="n"><span class="bright">QLatin1Char</span></span><span class="bright"></span><span class="p"><span class="bright">(</span></span><span class="bright"></span><span style="color: #766510"><span class="bright">'"'</span></span><span class="bright"></span><span class="p"><span class="bright">),</span></span><span class="bright"> </span><span class="n"><span class="bright">index1</span></span><span class="bright"> </span><span style="color: #aa2211"><span class="bright">+</span></span><span class="bright"> </span><span style="color: #601200"><span class="bright">1</span></span><span class="bright"></span><span class="p"><span class="bright">);</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="bright"></span><span style="color: #74777d"><span class="bright">// find next word separator</span></span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="n">index2</span> <span style="color: #aa2211">=</span> <span class="n">line</span><span class="p">.</span><span class="n">indexOf</span><span class="p">(</span><span class="n">QStringLiteral</span><span class="p">(</span><span style="color: #766510">"</span><span style="color: #bb6622">\"</span><span style="color: #766510"> </span><span style="color: #bb6622">\"</span><span style="color: #766510">"</span><span class="p">),</span> <span class="n">index1</span> <span style="color: #aa2211">+</span> <span style="color: #601200">1</span><span class="p">);</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">this could move to after the if() block on the next line.<br />
If index1 < 0, there's no point in calculating index2.</p></div></div><br /><div style="border: 1px solid #C7CCD9; border-radius: 3px;"><div style="padding: 0; background: #F7F7F7; border-color: #e3e4e8; border-style: solid; border-width: 0 0 1px 0; margin: 0;"><div style="color: #74777d; background: #eff2f4; padding: 6px 8px; overflow: hidden;"><a style="float: right; text-decoration: none;" href="https://phabricator.kde.org/D25572#inline-144662">View Inline</a><span style="color: #4b4d51; font-weight: bold;">kfilewidget.cpp:1777</span></div>
<div style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; white-space: pre-wrap; clear: both; padding: 4px 0; margin: 0;"><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span style="color: #74777d">// grab everything left until last character</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">            <span class="n">index2</span> <span style="color: #aa2211">=</span> <span class="n">line</span><span class="p">.</span><span class="n">length</span><span class="p">()</span> <span style="color: #aa2211">-</span><span style="color: #601200">1</span><span class="p">;</span>
</div><div style="padding: 0 8px; margin: 0 4px; background: rgba(151, 234, 151, .6);">        <span class="p">}</span>
</div></div></div>
<div style="margin: 8px 0; padding: 0 12px;"><p style="padding: 0; margin: 8px;">Isn't the last character a double-quote (in the normal case)? Don't we want to stop just before it, to avoid grabbing it?</p>

<p style="padding: 0; margin: 8px;">Of course this opens the question of what to do if the last character is NOT a double-quote, but<br />
<tt style="background: #ebebeb; font-size: 13px;">"file1.txt" "file2.txt</tt> looks weird. Well, getting <tt style="background: #ebebeb; font-size: 13px;">file2.tx</tt> as a result would be even weirder, so better go backwards from the end of the string until "not space and not double-quote", for some tolerance. (another case for the unittest)</p></div></div></div></div></div><br /><div><strong>REPOSITORY</strong><div><div>R241 KIO</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D25572">https://phabricator.kde.org/D25572</a></div></div><br /><div><strong>To: </strong>meven, Frameworks, ngraham, dfaure<br /><strong>Cc: </strong>kde-frameworks-devel, LeGast00n, GB_2, michaelh, ngraham, bruns<br /></div>