<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Strange behavior of the sort function, with zero-length column mode selection]]></title><description><![CDATA[<p dir="auto">Hi, <strong>All</strong>,</p>
<p dir="auto">I would like to get your feedback on this <strong>weird</strong> behavior. Could you confirm me that there is a <strong>problem</strong> ?</p>
<p dir="auto"><em>IMPORTANT</em> : Although, I installed the <strong><code>BetterMultiSelection</code></strong> plugin, on my <strong>local</strong> N++ <strong><code>v8.4.6</code></strong> configuration, I <strong>disabled</strong> this plugin during the tests !</p>
<p dir="auto">Follow <strong>exactly</strong> all the subsequent steps :</p>
<hr />
<ul>
<li>In a <strong>new</strong> tab, insert the text, below :</li>
</ul>
<pre><code class="language-diff">    xyz
    -PQR
    AB-C
    abc
    ABCDEF
    abcdef
    ABC-DEF
    -pqr
    ab-c
    x-yz
    X-YZ
    ABC
    abc-def
    XYZ
</code></pre>
<p dir="auto">Just note that these lines are <strong>randomly</strong> sorted.</p>
<ul>
<li>
<p dir="auto">Now, make a <strong>zero</strong>-length <strong>column</strong>-mode selection of <strong>all</strong> the lines, right after the <strong>four space</strong> chars ( indication <strong><code>Sel: 14x0</code></strong> in the <strong>status</strong> bar )</p>
</li>
<li>
<p dir="auto">Type in, for instance, a double-quote <strong><code>"</code></strong> ( to be sure that you’ve entered in the <strong>column</strong>-mode ! )</p>
</li>
<li>
<p dir="auto">Run the option <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong></p>
</li>
</ul>
<p dir="auto">=&gt; <strong>No</strong> modification occur !?</p>
<ul>
<li>
<p dir="auto">Hit the <strong><code>Del</code></strong> key to <strong>delete</strong> all the <strong><code>"</code></strong></p>
</li>
<li>
<p dir="auto">Run, again, the <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> option</p>
</li>
</ul>
<p dir="auto">=&gt; Still, <strong>no</strong> change occur !?</p>
<ul>
<li>
<p dir="auto">Hit the <strong><code>Left Arrow</code></strong> key to cancel the <strong>colum</strong> mode</p>
</li>
<li>
<p dir="auto">Again, make a <strong>zero</strong>-length <strong>column</strong>-mode selection of <strong>all</strong> the lines, right after the <strong>four space</strong> chars ( indication <strong><code>Sel: 14x0</code></strong> in the <strong>status</strong> bar )</p>
</li>
<li>
<p dir="auto">Select, for the <strong>last</strong> time,  the <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> option</p>
</li>
</ul>
<p dir="auto">=&gt; This time, as <strong>expected</strong>, the lines are <strong>correctly</strong> sorted ( <strong><code>Lexicographically Ascending</code></strong> ), as below :</p>
<pre><code class="language-diff">    -PQR
    -pqr
    AB-C
    ABC
    ABC-DEF
    ABCDEF
    X-YZ
    XYZ
    ab-c
    abc
    abc-def
    abcdef
    x-yz
    xyz
</code></pre>
<p dir="auto"><strong>Notes</strong> :</p>
<ul>
<li>
<p dir="auto">If, instead of the <strong>leading space</strong> chars, you insert a <strong>tabulation</strong> char, for <strong>all</strong> the lines and repeat the <strong>same</strong> steps, the problem persists :-(</p>
</li>
<li>
<p dir="auto">If the <strong><code>BetterMultiSelection</code></strong> is <strong>enabled</strong>, the problem is <strong>identical</strong>, too !</p>
</li>
</ul>
<hr />
<p dir="auto">Let’s try an <strong>other</strong> test :</p>
<ul>
<li>Insert the <strong>example</strong> test in a <strong>new</strong> tab</li>
</ul>
<pre><code class="language-diff">    xyz
    -PQR
    AB-C
    abc
    ABCDEF
    abcdef
    ABC-DEF
    -pqr
    ab-c
    x-yz
    X-YZ
    ABC
    abc-def
    XYZ
</code></pre>
<ul>
<li>
<p dir="auto">Make a <strong>zero</strong>-length <strong>column</strong>-mode selection of <strong>all</strong> the lines, right after the <strong>four space</strong> chars ( indication <strong><code>Sel: 14x0</code></strong> in the <strong>status</strong> bar )</p>
</li>
<li>
<p dir="auto">Type in, for instance, the <strong>sharp</strong> char  <strong><code>#</code></strong> ( to be sure that you’ve entered in the <strong>column</strong>-mode ! )</p>
</li>
<li>
<p dir="auto">Run the <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> option</p>
</li>
</ul>
<p dir="auto">=&gt; As said above, <strong>no</strong> modification occur !?</p>
<ul>
<li>
<p dir="auto">Now, hit <strong>simultaneously</strong> the <strong><code>Alt</code></strong> and <strong><code>Shift</code></strong> keys and successively the <strong><code>Right Arrow</code></strong> and <strong><code>Left Arrow</code></strong> keys</p>
</li>
<li>
<p dir="auto">Run, again, the <strong><code>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending</code></strong> option</p>
</li>
</ul>
<p dir="auto">=&gt; This time, <strong>although</strong> the resulting <strong>column</strong> mode is <em>STILL</em> a <strong>zero-length</strong> selection, the behaviour of the sort is correct and gives, as <strong>epected</strong> :</p>
<pre><code class="language-diff">    -PQR
    -pqr
    AB-C
    ABC
    ABC-DEF
    ABCDEF
    X-YZ
    XYZ
    ab-c
    abc
    abc-def
    abcdef
    x-yz
    xyz
</code></pre>
<hr />
<p dir="auto">In summary, sort does <strong>not</strong> seem to occur when, <strong>simultaneously</strong> :</p>
<ul>
<li>
<p dir="auto">A <strong>column</strong>-mode selection is active</p>
</li>
<li>
<p dir="auto">A char have been <strong>added</strong> or <strong>deleted</strong></p>
</li>
<li>
<p dir="auto">The <strong>column</strong>-mode selection is a <strong>zero-length</strong> one</p>
</li>
</ul>
<hr />
<p dir="auto">On the contrary, the sort seems <strong>correct</strong> if :</p>
<p dir="auto">A <strong>non-zero</strong> length <strong>column</strong>-mode selection is active<br />
<em>OR</em><br />
A <strong>resulting</strong> <em>zero-legnth</em> <strong>column</strong>-mode selection is active<br />
<em>OR</em><br />
<strong>No</strong> modification of the <strong>column-mode</strong> selection have been occurred</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto">P.S. :</p>
<pre><code class="language-diff">Notepad++ v8.4.6   (64-bit)
Build time : Sep 25 2022 - 19:51:39
Path : E:\846_x64_RC3\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Pro (64-bit) 
OS Version : 21H2
OS Build : 19044.2075
Current ANSI codepage : 1252
Plugins : 
    mimeTools (2.8)
    NppConverter (4.4)
    NppExport (0.4)
    ComparePlus (1)
    BetterMultiSelection (1.5)
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/topic/23564/strange-behavior-of-the-sort-function-with-zero-length-column-mode-selection</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Apr 2026 11:47:27 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/23564.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 06 Oct 2022 11:29:21 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Tue, 15 Oct 2024 01:19:16 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/97098">Strange behavior of the sort function, with zero-length column mode selection</a>:</p>
<blockquote>
<p dir="auto">Is Peter showing his BASIC roots here by using &lt;&gt;?</p>
</blockquote>
<pre><code>100 PRINT "BASIC FOREVER"
200 GOTO 100
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/97099</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/97099</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Tue, 15 Oct 2024 01:19:16 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Tue, 15 Oct 2024 00:30:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> :</p>
<blockquote>
<p dir="auto"><a href="http://SelectionToRectangle.py" rel="nofollow ugc">SelectionToRectangle.py</a> v2022.10.06</p>
</blockquote>
<p dir="auto">In Peter’s Oct 6, 2022 11:20am posting, the script code contained this line:</p>
<p dir="auto"><code>if editor.getSelectionMode()&lt;&gt;SELECTIONMODE.RECTANGLE:</code></p>
<p dir="auto">Is Peter showing his BASIC roots here by using <code>&lt;&gt;</code>?</p>
<p dir="auto">Proper Python would be to use <code>!=</code> (or so one would think… keep reading…).</p>
<p dir="auto">What caused me to notice this is that I exclusively use Python3 (and PythonScript v3.x) these days, and such a thing causes an error there, e.g.</p>
<pre><code>Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)]
&gt;Initialisation took 3078ms
&gt;Ready.
&gt;&gt;&gt; a = 3
&gt;&gt;&gt; a &lt;&gt; 4
  File "&lt;console&gt;", line 1
    a &lt;&gt; 4
      ^^
SyntaxError: invalid syntax
</code></pre>
<p dir="auto">This made me dig up PythonScript 2 and try it there, where, indeed, it is fine:</p>
<pre><code>Python 2.7.18 (v2.7.18:8d21aa21f2, Apr 20 2020, 13:25:05) [MSC v.1500 64 bit (AMD64)]
&gt;Initialisation took 2703ms
&gt;Ready.
&gt;&gt;&gt; a = 3
&gt;&gt;&gt; a &lt;&gt; 4
True
</code></pre>
<p dir="auto">Probably the moral to the story is to just not use <code>&lt;&gt;</code> with Python, whatever version.  :-)</p>
<p dir="auto">Perhaps some further interesting reading:  <a href="https://stackoverflow.com/questions/16749121" rel="nofollow ugc">https://stackoverflow.com/questions/16749121</a></p>
]]></description><link>https://community.notepad-plus-plus.org/post/97098</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/97098</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Tue, 15 Oct 2024 00:30:10 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 02 Dec 2022 21:50:08 GMT]]></title><description><![CDATA[<p dir="auto">The “Strange behavior of the sort function, with zero-length column mode selection” has been <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/commit/f6d36235cd1dbcbfdccada385c32b241aae426e6" rel="nofollow ugc">SOLVED</a> by the developers and will be in the next release, presumably 8.4.8.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/82196</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/82196</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 02 Dec 2022 21:50:08 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Mon, 10 Oct 2022 01:03:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/80428">Strange behavior of the sort function, with zero-length column mode selection</a>:</p>
<blockquote>
<p dir="auto">two ways to reproduce this wrong behavior</p>
</blockquote>
<p dir="auto">As I never do those two actions, that isn’t a way I’m getting into the circumstance.</p>
<p dir="auto">My problem with it mainly occurs when I am running a different instance of N++ to test a script in a “clean” setup.  I tell it to create a New Script and it wants to save the file in the correct folder but in my daily use Notepad++.</p>
<p dir="auto">I have several workarounds for this, but it is annoying behavior to say the least.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80430</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80430</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Mon, 10 Oct 2022 01:03:57 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Sun, 09 Oct 2022 22:30:32 GMT]]></title><description><![CDATA[<p dir="auto">Hello <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a> and <strong>All</strong>,</p>
<p dir="auto">In the post <strong>above</strong>, of this discussion :</p>
<p dir="auto"><a href="https://community.notepad-plus-plus.org/post/80361">https://community.notepad-plus-plus.org/post/80361</a></p>
<p dir="auto">You said that you met the problem, sometimes in the <strong>past</strong> and that you haven’t find a solution yet to the fact that running the <strong><code>Plugins &gt; PythonScript &gt; New Script</code></strong> does <strong>not</strong> open the folder <strong><code>Local N++ install\Plugins\Config\PythonScript\Scripts</code></strong>, in the case of a <strong>local</strong> N++ install !</p>
<p dir="auto">I’ve already found out <strong>two</strong> ways to reproduce this <strong>wrong</strong> behavior and also how to get the <strong>right</strong> folder ! Could you, <strong>Alan</strong>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> or <strong>someone</strong> else confirm my <strong>hypotheses</strong> ?</p>
<hr />
<p dir="auto">A <strong>wrong</strong> folder destination, when using the <strong><code>Plugins &gt; PythonScript &gt; New Script</code></strong> option, may occur when :</p>
<ul>
<li>
<p dir="auto">You’re trying, by mistake, to open an <strong>already</strong> opened file in your <strong>current</strong> N++ session which is <strong>not</strong> saved in the <strong><code>...\Plugins\Config\PythonScript\Scripts</code></strong> folder</p>
</li>
<li>
<p dir="auto">You’re saving a <strong><code>new_x</code></strong> file, in a <strong>specific</strong> folder, different from the <strong><code>...\Plugins\Config\PythonScript\Scripts</code></strong> folder</p>
</li>
</ul>
<hr />
<p dir="auto">So, an <strong>easy</strong> solution is to <strong>re</strong>-open a <strong><code>Python</code></strong> script of your <strong>current</strong> session ! Afterwards, any use of the <strong><code>Plugins &gt; PythonScript &gt; New Script</code></strong>  option should open the <strong>right</strong> folder <strong><code>...\Plugins\Config\PythonScript\Scripts</code></strong> ;-))</p>
<p dir="auto"><strong>Remark</strong> : Note that holding the <strong><code>Ctrl</code></strong> key, while using the <strong><code>Plugins\Python Scripts\Scripts\"Script Name"</code></strong> option, does <strong>not</strong> help in this matter :-((</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80428</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80428</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Sun, 09 Oct 2022 22:30:32 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 07 Oct 2022 12:10:20 GMT]]></title><description><![CDATA[<p dir="auto">Hi <strong>all</strong>,</p>
<p dir="auto">As promised, I created a <strong>new</strong> issue concerning this problem :</p>
<p dir="auto"><a href="https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12299#issue-1401062911" rel="nofollow ugc">https://github.com/notepad-plus-plus/notepad-plus-plus/issues/12299#issue-1401062911</a></p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80370</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80370</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Oct 2022 12:10:20 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 07 Oct 2022 04:09:30 GMT]]></title><description><![CDATA[<p dir="auto">Hi, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/12335">@terry-r</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> and <strong>All</strong></p>
<p dir="auto">I’m really <strong>perplexed</strong> !!??</p>
<ul>
<li>
<p dir="auto">On my <strong><code>USB</code></strong> drive, I created a <strong>new</strong> folder <strong><code>E:\846_x64</code></strong></p>
</li>
<li>
<p dir="auto">Then, I moved the <strong><code>npp.8.4.6.portable.x64.7z</code></strong> archive, that I <strong>kept</strong>, from the folder <strong><code>E:\846_x64_RC3</code></strong> to the <strong>new</strong> folder <strong><code>E:\846_x64</code></strong></p>
</li>
<li>
<p dir="auto">I opened this archive and <strong>extracted</strong> all the contents in the <strong><code>E:\846_x64</code></strong> folder</p>
</li>
<li>
<p dir="auto">I defined my <strong>preferred</strong> parameters in <strong><code>Settings &gt; Preferences...</code></strong></p>
</li>
<li>
<p dir="auto">And I downloaded the <strong><code>PythonScript</code></strong> plugin via the <strong><code>Plugin Admin</code></strong></p>
</li>
</ul>
<p dir="auto">Bingo ! I’m pleased to tell you that, <strong>whatever</strong> the current tab, as soon as I select the <strong><code>Plugins &gt; PythonScript &gt; New Script</code></strong> option, the <strong><code>Save inder</code></strong> window <strong>always</strong> opens in <strong><code>E:\846_x64\plugins\Config\PythonScript\Scripts</code></strong> ;-))</p>
<ul>
<li>Finally, I added the <strong><code>ComparePlus</code></strong> and <strong><code>BetterMultiSelection</code></strong> plugins and everything is <strong>still</strong> OK !</li>
</ul>
<hr />
<p dir="auto">So, I don’t see why it’s <strong>OK</strong> on a <strong>local</strong> N++ install, in folder <strong><code>E:\846_x64</code></strong> and <strong>KO</strong> on a <em>SAME</em> <strong>local</strong> N++ install, in folder <strong><code>E:\846_x64_RC3</code></strong> ???</p>
<p dir="auto">Anyway, my problem is <strong>solved</strong> !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<p dir="auto">…A quarter of an hour <strong>later</strong>, even if I use my <strong>old</strong> local N++ version, within the <strong><code>E:\846_x64_RC3</code></strong> folder, everything seems <strong>OK</strong>, again ??? Really <strong>confusing</strong> !</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80363</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80363</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Oct 2022 04:09:30 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 07 Oct 2022 02:05:44 GMT]]></title><description><![CDATA[<p dir="auto">Hi <strong>All</strong>,</p>
<p dir="auto">Could it be connected with the fact of putting a <strong>local N++</strong> install on a <strong>removable</strong> drive ?</p>
<p dir="auto">BR</p>
<p dir="auto">guy038</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80362</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80362</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Oct 2022 02:05:44 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 07 Oct 2022 01:44:17 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">I also have problems with the PythonScript &gt; New Script command suggesting a folder that isn’t the one I want.  It typically suggests a folder that is the scripts folder for another version of Notepad++ that I’ve recently used.  I’ve no idea why this happens; I’ve posted about this before but never came to a resolution.  So…I’m just doubly careful when I save a new script, such that it is going into the correct folder!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80361</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80361</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 07 Oct 2022 01:44:17 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 07 Oct 2022 01:38:37 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> said in <a href="/post/80359">Strange behavior of the sort function, with zero-length column mode selection</a>:</p>
<blockquote>
<p dir="auto">However, I do not understand why IF I select again the Plugins &gt; PythonScript &gt; New Script option, this time, the Save under… windows proposes to save the future .py file in the \E folder instead of the normal location E:\846_x64_RC3\plugins\Config\PythonScript\Scripts ?!</p>
</blockquote>
<p dir="auto">After reading that I’m wondering if a variable has been set if the first use was in relation to the E:\ drive. Now any successive use of this will use the pre-set variable of E:\ as a starting point since it’s already set.</p>
<p dir="auto">Possibly a test might be to complete a fresh start of NPP and do a new script and see what the Save Under proposes.</p>
<p dir="auto">Terry</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80360</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80360</guid><dc:creator><![CDATA[Terry R]]></dc:creator><pubDate>Fri, 07 Oct 2022 01:38:37 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Fri, 07 Oct 2022 01:50:06 GMT]]></title><description><![CDATA[<p dir="auto">Hello, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@alan-kilborn</a>, <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> and <strong>All</strong>,</p>
<p dir="auto">Many thanks for your <strong>feedback</strong> ! I now understand the problem and, certainly, the <strong>last</strong> suggestion of <strong>Alan</strong> seems the <strong>correct</strong> one !</p>
<p dir="auto">I’ll create a <strong>new</strong> issue, very soon ! We’ll just have to live what this <strong>tiny</strong> problem !</p>
<p dir="auto">Of course, we could, as well, have simply used the <strong><code>Stream Selection</code></strong>, right <strong>before</strong> the sort. In this case, the result is <strong>always</strong> correct !</p>
<hr />
<p dir="auto">Now, <strong>Peter</strong> and <strong>Alan</strong>, I’m <strong>upset</strong> by a behavior, a bit <strong>off-topic</strong>, relative to the <strong><code>PythonScript</code></strong> plugin. Let me explain :</p>
<p dir="auto">On my new <strong><code>Windows 10</code></strong> laptop, I still did <strong>not</strong> transfer all my <strong>personal</strong> data from my old <strong><code>XP</code></strong> laptop. So, in the meanwhile, I use an <strong><code>USB</code></strong> key ( <strong><code>E:</code></strong> ), containing some folders whose one is <strong><code>846_x64_RC3</code></strong> which contains the <strong>last locale</strong> N++ version</p>
<p dir="auto">After installing, as you suggested, the <strong><code>PythonScript</code></strong> plugin with the <strong><code>Plugins &gt; Plugin Admin...</code></strong> option, I selected the <strong><code>Plugins &gt; PythonScript &gt; New Script</code></strong> option which created an <strong>empty</strong> <strong><code>Test.py</code></strong> file in the folder <strong><code>E:\846_x64_RC3\plugins\Config\PythonScript\Scripts</code></strong>. Then, I <strong>pasted</strong> the contents of the @pterjones script, below, and re-saved it  :</p>
<pre><code class="language-py"># encoding=utf-8
"""
Derived from SelectionToRectangle.py from 22890-simplest.py, in response to https://community.notepad-plus-plus.org/topic/23564,
which had (accidentally) changed a Column Selection to a Multi-Selection instead. This converts a multi-selection to a column-selection
"""
from Npp import notepad, editor, SELECTIONMODE, STATUSBARSECTION

#console.clear()
#console.write("PRE:  {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))

if not(editor.selectionIsRectangle()) and (editor.getMultipleSelection()):
    ss,se = editor.getSelectionStart(), editor.getSelectionEnd()
    #console.write("GET:  {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))
    editor.setSelection(ss,se)
    #console.write("SET:  {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))
    editor.setSelectionMode( SELECTIONMODE.RECTANGLE )
    #console.write("RECT: {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))

notepad.activateFile(notepad.getCurrentFilename()) # use the activateFile() command to refresh UI; otherwise, it doesn't _look_ like column/rectangle select)
#console.write("POST: {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))
</code></pre>
<p dir="auto">The <em>INPUT</em> text was in <strong><code>E:\xxx.txt</code></strong> file and, after following the <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@peterjones</a> instructions, everything was OK !</p>
<hr />
<p dir="auto">However, I do <strong>not</strong> understand why <em>IF</em> I select again the <strong><code>Plugins &gt; PythonScript &gt; New Script</code></strong> option, this time, the <strong><code>Save under...</code></strong> windows proposes to <strong>save</strong> the future <strong><code>.py</code></strong> file in the <strong><code>\E</code></strong> folder <strong>instead</strong> of the <strong>normal</strong> location <strong><code>E:\846_x64_RC3\plugins\Config\PythonScript\Scripts</code></strong> ?!</p>
<p dir="auto">Do you have some hints about it ? I <strong>surely</strong> miss something obvious !</p>
<p dir="auto">Thanks, in advance !</p>
<p dir="auto">Best Regards,</p>
<p dir="auto">guy038</p>
<pre><code class="language-diff">Notepad++ v8.4.6   (64-bit)
Build time : Sep 25 2022 - 19:51:39
Path : E:\846_x64_RC3\notepad++.exe
Command Line : 
Admin mode : OFF
Local Conf mode : ON
Cloud Config : OFF
OS Name : Windows 10 Pro (64-bit) 
OS Version : 21H2
OS Build : 19044.2075
Current ANSI codepage : 1252
Plugins : 
    mimeTools (2.8)
    NppConverter (4.4)
    NppExport (0.4)
    ComparePlus (1)
    BetterMultiSelection (1.5)
    PythonScript (2)
</code></pre>
<p dir="auto">The command line <strong><code>set</code></strong> gives :</p>
<pre><code class="language-diff">ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\Guy\AppData\Roaming
BRB=C:\Program Files\HP\Sure Click\bin
BRS=C:\Program Files\HP\Sure Click\servers
CommonProgramFiles=C:\Program Files\Common Files
CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files
CommonProgramW6432=C:\Program Files\Common Files
COMPUTERNAME=GUYTOU
ComSpec=C:\windows\system32\cmd.exe
DriverData=C:\Windows\System32\Drivers\DriverData
FPS_BROWSER_APP_PROFILE_STRING=Internet Explorer
FPS_BROWSER_USER_PROFILE_STRING=Default
HOMEDRIVE=C:
HOMEPATH=\Users\Guy
LOCALAPPDATA=C:\Users\Guy\AppData\Local
LOGONSERVER=\\GUYTOU
NUMBER_OF_PROCESSORS=8
OneDrive=C:\Users\Guy\OneDrive
OnlineServices=Online Services
OS=Windows_NT
Path=: E:\846_x64_RC3\notepad++.exe
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
platformcode=AN
PROCESSOR_ARCHITECTURE=AMD64
PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 140 Stepping 1, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=8c01
ProgramData=C:\ProgramData
ProgramFiles=C:\Program Files
ProgramFiles(x86)=C:\Program Files (x86)
ProgramW6432=C:\Program Files
PROMPT=$P$G
PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\windows\system32\WindowsPowerShell\v1.0\Modules
PUBLIC=C:\Users\Public
RegionCode=EMEA
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\windows
TEMP=C:\Users\Guy\AppData\Local\Temp
TMP=C:\Users\Guy\AppData\Local\Temp
USERDOMAIN=GUYTOU
USERDOMAIN_ROAMINGPROFILE=GUYTOU
USERNAME=Guy
USERPROFILE=C:\Users\Guy
windir=C:\windows
ZES_ENABLE_SYSMAN=1
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/80359</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80359</guid><dc:creator><![CDATA[guy038]]></dc:creator><pubDate>Fri, 07 Oct 2022 01:50:06 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Thu, 06 Oct 2022 17:56:26 GMT]]></title><description><![CDATA[<p dir="auto">I’d think changing <a href="https://github.com/notepad-plus-plus/notepad-plus-plus/blob/bcaf0f00b5e84c0c081c83233233717cd6c9b2ad/PowerEditor/src/NppCommands.cpp#L653" rel="nofollow ugc">THIS</a> from:</p>
<pre><code>if (_pEditView-&gt;execute(SCI_SELECTIONISRECTANGLE))
</code></pre>
<p dir="auto">to:</p>
<pre><code>if ((_pEditView-&gt;execute(SCI_SELECTIONISRECTANGLE)) || (_pEditView-&gt;execute(SCI_GETSELECTIONMODE) == SC_SEL_THIN))
</code></pre>
<p dir="auto">should fix it.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80336</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80336</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 06 Oct 2022 17:56:26 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Thu, 06 Oct 2022 15:35:13 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/80325">Strange behavior of the sort function, with zero-length column mode selection</a>:</p>
<blockquote>
<p dir="auto">To me it sounds like Guy found a Notepad++ bug. …</p>
</blockquote>
<p dir="auto">From that perspective, it does sound like it doesn’t meet user expectations.</p>
<p dir="auto">So yeah, Guy should go ahead and report it as a bug.  If he does, it would be best to explain that SC_SEL_RECTANGLE sorts as expected, but SC_SEL_THIN does not sort when it is expected to do so.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80327</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80327</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 06 Oct 2022 15:35:13 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Thu, 06 Oct 2022 15:29:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/3841">@PeterJones</a> said in <a href="/post/80324">Strange behavior of the sort function, with zero-length column mode selection</a>:</p>
<blockquote>
<p dir="auto">So what Guy found is not a bug…the line operation sorting functions only work with stream or rectangle selections, not with “thin” selections.</p>
</blockquote>
<p dir="auto">To me it sounds like Guy found a Notepad++ bug.  When sorting, a zero-width selection – declared by code as “thin” or not, user doesn’t care about that distinction in this circumstance – over a number of lines is supposed to use as the sort key the data starting in the column of the selection and continuing to end-of-line (for each line).  Note that this is a bit different from a sort using a non-zero width column selection, where the sort key is only the text shown as selected on each line.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80325</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80325</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 06 Oct 2022 15:29:10 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Wed, 16 Oct 2024 17:59:59 GMT]]></title><description><![CDATA[<p dir="auto">Some more research and experimentation:</p>
<p dir="auto">The reason it changed mode out of Rectangle mode is because Scintilla has a selection mode called <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_SETSELECTIONMODE" rel="nofollow ugc">SC_SEL_THIN</a> which indicates “the mode after a rectangular selection has been typed into and ensures that no characters are selected”.  So what Guy found is not a bug: rather, Scintilla intentionally leaves pure Rectangle Selection Mode (SC_SEL_RECTANGLE) after you make edits; and the line operation sorting functions only work with stream or rectangle selections, not with “thin” selections or multi-selections.</p>
<p dir="auto">The script I showed above will get you back into full rectangle mode from the THIN mode, but not from any others.</p>
<p dir="auto">I have now updated my original <code>SelectionToRectangle.py</code> to work whether the active selection is starting from a normal (“stream”) selection, from an edited-column (“thin”) selection, or from a multi-selection: all three of those will be converted into a column-mode selection.  And if it’s already a column-mode (“rectangle”), it will remain unchanged.</p>
<p dir="auto"><strong><code>SelectionToRectangle.py</code> v2022.10.06</strong></p>
<pre><code># encoding=utf-8
"""
Derived from 22890-simplest.py, in response to https://community.notepad-plus-plus.org/topic/22890/

2022-Oct-06: modify based on https://community.notepad-plus-plus.org/topic/23564 to convert either stream selection (old behavior) or multi-selection (new behavior) to a single column selection

This is the simplest paradigm for converting a stream (normal) selection to rectangular (column):
1) Click or arrow to where you want to start selecting
2) Shift+Click or Shift+arrow to get to the end of the selection (ie, do a normal selection)
3) Run this script to convert the selection from STREAM to rectangle and refresh the screen automatically to see it

You can also start with a Multi-Selection (multiple Ctrl+Clicks) and convert it, with the start of the column at the lowest selection-start, and the end of the selection at the highest selection-end
"""
from Npp import notepad, editor, SELECTIONMODE, STATUSBARSECTION

if editor.getSelectionMode()==SELECTIONMODE.THIN:    # this is the mode after making an edit in rectangle(column) mode
    ss,se = editor.getSelectionStart(), editor.getSelectionEnd()
    editor.setSelection(ss,se)

if editor.getSelectionMode()==SELECTIONMODE.STREAM and editor.getSelections()&gt;1:    # this is multi-selection mode
    ss = None
    se = None

    for si in range(0, editor.getSelections()):
        s0 = editor.getSelectionNStart(si)
        s1 = editor.getSelectionNEnd(si)
        if ss is None or s0 &lt; ss: ss = s0
        if se is None or s1 &gt; se: se = s1

    editor.setSelection(ss,se)

if editor.getSelectionMode()!=SELECTIONMODE.RECTANGLE:
    editor.setSelectionMode( SELECTIONMODE.RECTANGLE )
    notepad.activateFile(notepad.getCurrentFilename()) # use the activateFile() command to refresh UI; otherwise, it doesn't _look_ like column/rectangle select)

</code></pre>
<p dir="auto">----<br />
2024-Oct-16 Fix: instead of using <code>&lt;&gt;</code> for “not equal”, use <code>!=</code> (see <a href="/post/97098">2024-Oct-14</a> post below for reasons)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80324</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80324</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Wed, 16 Oct 2024 17:59:59 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Thu, 06 Oct 2022 14:01:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a> ,</p>
<p dir="auto">Alan reminded me in chat about the conversation <a href="https://community.notepad-plus-plus.org/topic/22890/pythonscript-toggleable-script/31">PythonScript Toggleable Script?</a>, where I developed <a href="http://SelectionToRectangle.py" rel="nofollow ugc">SelectionToRectangle.py</a>, which converted a normal stream selection to a column (rectangle) selection.</p>
<p dir="auto">Using the concepts from that, I saw that after your manipulation (above) the selection converts from a rectangle selection to a multi-selection.  If I <em>just</em> ran the <code>SelectionToRectangle.py</code>, the modes <em>claim</em> to be a rectangular selection again… but looking at the selection start/end, it’s a one-row rectangle, so not very columnar.</p>
<p dir="auto">However, before doing the conversion, the multi-selection still had the original extents for the beginning and end of selection.  So using those values to create a new stream selection, and then using the SelectionToRectangle to convert to rectangular from that new stream, I think it works as desired:</p>
<pre><code>    one
    two
    three
    four
</code></pre>
<p dir="auto">Instructions:</p>
<ol start="0">
<li>Save this script, and optionally assign it a keyboard shortcut</li>
<li>use the <code>one</code>…<code>four</code> text above, do a column selection between the fourth space and the letters</li>
<li>type <code>"</code> then backspace to replicate Guy’s issue</li>
<li>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending – order should still be one, two, three, four, because it doesn’t sort because of multi-selection</li>
<li>run this script</li>
<li>Edit &gt; Line Operations &gt; Sort Lines Lexicographically Ascending – order should now be four, one, three, two, because it went back to column/rectangle-selection</li>
</ol>
<pre><code># encoding=utf-8
"""
Derived from SelectionToRectangle.py from 22890-simplest.py, in response to https://community.notepad-plus-plus.org/topic/23564,
which had (accidentally) changed a Column Selection to a Multi-Selection instead. This converts a multi-selection to a column-selection
"""
from Npp import notepad, editor, SELECTIONMODE, STATUSBARSECTION

#console.clear()
#console.write("PRE:  {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))

if not(editor.selectionIsRectangle()) and (editor.getMultipleSelection()):
    ss,se = editor.getSelectionStart(), editor.getSelectionEnd()
    #console.write("GET:  {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))
    editor.setSelection(ss,se)
    #console.write("SET:  {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))
    editor.setSelectionMode( SELECTIONMODE.RECTANGLE )
    #console.write("RECT: {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))

notepad.activateFile(notepad.getCurrentFilename()) # use the activateFile() command to refresh UI; otherwise, it doesn't _look_ like column/rectangle select)
#console.write("POST: {}..{} R:{} M:{}\n".format(editor.getSelectionStart(), editor.getSelectionEnd(), editor.selectionIsRectangle(), editor.getMultipleSelection()))
</code></pre>
]]></description><link>https://community.notepad-plus-plus.org/post/80313</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80313</guid><dc:creator><![CDATA[PeterJones]]></dc:creator><pubDate>Thu, 06 Oct 2022 14:01:51 GMT</pubDate></item><item><title><![CDATA[Reply to Strange behavior of the sort function, with zero-length column mode selection on Thu, 06 Oct 2022 13:01:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/195">@guy038</a></p>
<p dir="auto">If you make a column selection, then the Scintilla function <a href="https://www.scintilla.org/ScintillaDoc.html#SCI_SELECTIONISRECTANGLE" rel="nofollow ugc">SCI_SELECTIONISRECTANGLE</a> will return 1 meaning true.</p>
<p dir="auto">However, if after making the column selection, you use it to modify text, a call to SCI_SELECTIONISRECTANGLE will then return 0 meaning false, even though you can plainly see with your eyes that your column selection is still reasonable and valid.  Apparently the column selection is now considered “n” separate selections (multi-select), where “n” is the number of lines covered by the selection.  And…subsequent actions that depend upon column mode will possibly act strangely, as you’ve discovered.</p>
<p dir="auto">You can try checking the Scintilla mode yourself by going to the PythonScript console window and typing <code>editor.selectionIsRectangle()</code> at the <code>&gt;&gt;&gt;</code> prompt and pressing Enter, after you’ve set up your desired conditions in the editing window.  This will show you what Scintilla thinks the current state is.  Of course, you’d have to add PythonScript to your plugins for this.</p>
<p dir="auto">Note that from the PS console window, to get back to the editing window without altering your previously made selection, you might want to use the “two taps on the Windows key” trick, to experiment further.  Clicking with the mouse into the editor window will destroy your previously set up selection.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/80311</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/80311</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 06 Oct 2022 13:01:45 GMT</pubDate></item></channel></rss>