#222 "No block" on file insert in rectangle mode


If you are in "rectangle mode" (^KT x), inserting a file (^KR) does not work...instead, you get the "no block" error.

My guess (though I have not read the code) is that the "insert file" code is doing the semantic equivalent of "open the selected document in an unshown window, select all of it, copy it into the current document at the current position, and then close the input file." Or, in control-key terms, ^KU ^KB ^KV ^KK ^KP ^KC ^KN ^KX.

It makes sense that this would fail in rectangle mode because the input file starts at column 0 and the "end" of the file is probably a newline, also at column 0, so there is nothing selected and nothing to copy...so an easy fix would be to check for rectangle mode before attempting the select, and then switching back after the copy.


  • Joe Allen
    Joe Allen

    In rectangle mode, ^K R works, but replaces the currently selected rectangle with the file. I've now modified it to insert a file even if the selected rectangle has zero width. Before it said "No block".

  • Joe Allen
    Joe Allen

    • status: open --> closed
  • This still produces very unintuitive behavior.

    Specifically, it means that if I have the screen split with ^KO, and am in the top screen, while there's some rectangle-mode text selected in the bottom screen, and I insert a file, it appears in the bottom screen, and not in the top screen.

    I was lucky today--if the "bottom screen" was not displayed, I would have no idea why the file I was trying to insert was not appearing.

    I would argue that in all cases, ^KR should insert a file such that the first character in the file appears at the cursor's current location, and so on, with all characters being pushed forward. Perhaps in rectangle mode it should push current text to the right instead of downward...but using the location of the block instead of the cursor doesn't make sense and is not sufficiently documented.

    Or maybe I'm simply confused about the purpose of "insert file" or "rectangle mode?"