bugGNU Octave - Bugs: bug #47340, wrong tab completion on directory...

 
 

bug #47340: wrong tab completion on directory names with spaces

Submitter:  Hartmut <hardy>
Submitted:  Fri 04 Mar 2016 11:05:49 PM UTC
   
 
Category:  Interpreter Severity:  2 - Minor
Priority:  1 - Later Item Group:  Inaccurate Result
Status:  Postponed Assigned to:  None
Originator Name:  Hartmut Open/Closed:  * Open
Release:  * dev Operating System:  * Any
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Sat 19 Nov 2016 12:13:43 PM UTC, comment #6: 

This behavior is still present in Octave 4.2.0.

Hartmut <hardy>
Tue 08 Mar 2016 01:58:34 AM UTC, comment #5: 

Hartmut, what you propose in comment #3 seems similar to what Philip showed that Matlab does.

However, Octave's parser is a law unto itself.  In Octave the syntax


cd 'part 1'/'part 2'


is not interpreted as


cd 'part 1/part 2'


but instead as passing two arguments to cd.  The first is "part 1" and the second is "/'part 2'" (including the single quotes as part of the argument).

I think that it would be easier to get readline to insert and remove the quotes around the / as it goes.

I may get around to this once the multi-level directory completion patch at bug #44095 is applied, and perhaps after bug #46458.

Lachlan Andrew <lachlan>
Mon 07 Mar 2016 11:46:07 AM UTC, comment #4: 

The other way (for tab completion involving folder/file names) would be to incorporate file browser capabilities using e.g., glob().
That would require recognition by ?readline? that a path is to be completed, while AFAIU currently it just searches the command history. (I may be very wrong here)
An advantage would be that non-existing paths can be weeded out before <Return> is pressed and relevant error messages are generated.

AFAICS that is the way that Matlab does it.  I attached a screenshot of ML r2016a prerelease where I started with "cd Prog" and then presses TAB repeatedly.  As can be seen on that screenshot, I started from a completely different folder.



Philip Nienhuis <philipnienhuis>
Group Member
Mon 07 Mar 2016 09:53:22 AM UTC, comment #3: 

Stop. Here is an idea how to better handle this:

Suppose you have a folder "my data" in your current directory, which itself has a subfolder "test folder" in it. How about the following behavior:

  • "cd my[tab]" leads to "cd 'my data'" ( or even better lead to "cd 'my data'/" )
  • afterwards the user can finish by pressing Enter (this was my original usecase) and everything is fine
  • OR the user can continue typing like this "cd 'my data'/tes[tab]" which should then be auto completed to "cd 'my data'/'test folder'". This results seems to be valid Octave syntax for a folder name as well. So pressing Enter will now also suceeed.


In order to facility the above behavior (at least) two changes are necessary:

  • The auto completion of folder names with spaces in the name, should be closed with a quote sign. (original issue) Optionally we could still add the trailing slash as well.
  • Inputs like "cd 'my data'/tes[tab]" should be properly auto completed.


I hope I could make it clear how me idea is ment. I think it would make it possible that both mentioned use cases work simultanously :)

Hartmut <hardy>
Mon 07 Mar 2016 09:41:27 AM UTC, comment #2: 

Yes, I was naively expecting a final quote after the auto completion of a folder name with a space sign inside. In my presented usecase of a "cd" command in the interactive console, this seemed the obvious behavior to me.

But you are right. If we add a closing quote in this case, it would keep the user from expanding the path further into subdirectories by simply typing some more characters and pressing tab again. I had not thought about this other usecase before. (I think the behavior of first adding a closing quote, which would lateron be automaticly removed when the user continues typing, is too weired. This would most probably only irritate most users.)

I personally would be fine with just closing this bug report now. I have no other and still consistent idea how to better handle this.

Just for completeness, here is what other readlines do in this case:

  • The linux bash shell autocompletes "cd my[tab]" to "cd my\ data/". I think this only works because in this shell space signes can be escaped with a bashlash. This is a very elegant solution to our problem. But currently it does not work in Octave, because slashes and bashlashes are both used for folder name separation (as is necessary to support linux and windows file name conventions).


  • In the Windows command console 'cd my[tab]' autocompletes to 'cd "my data"'. This is what I was naively expecting. But you are right that this keeps the user from doing auto completion in a nested way, which is a valid use case as well.


  • I haven't tested what  Matlab does.



Hartmut <hardy>
Mon 07 Mar 2016 02:23:13 AM UTC, comment #1: 

Are you saying that the bug is that the final quote is missing?

Since Octave has no way of telling whether or not this is the last component in the path, it leaves the user to close the quotes.

What would you expect if you wanted to change directory to
  'my dataset/day 1/'
?  (Note that multi-level expansion is supported by the patch at bug #44095.)

Would you like it to add the trailing quote and then get the user to type "backspace" to continue?  Or would you like
  'my dataset/'da<TAB>
to remove the second quote and perform the completion?

Lachlan Andrew <lachlan>
Fri 04 Mar 2016 11:05:49 PM UTC, original submission:  

Here is how to reproduce the behavior:

  • start Octave
  • navigate to a folder, that has a SUBfolder with a space in the folder name, e.g. a subfolder "my dataset"
  • type "cd my" into the command line and press the tab key for auto completion
  • the auto-completed result in the command line will be "cd 'my dataset\". Note that the quote sign at the end is missing.
  • pressing the enter key now, will obviously result in an error message


So the auto completion of folder names does not work properly.

Note that the auto completion of FILE names does work properly. (This error on folder names might be due to the trailing backslash that is appended to folder names.)

This happens on Linux and Windows. It happens with Octave-4.0.1-rc3 as well as with the 4.0.0 release.

Hartmut <hardy>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by mtmiller (Updated the item)
  • -email is unavailable- added by lachlan (Posted a comment)
  • -email is unavailable- added by hardy (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 9 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-08-22 mtmiller Priority3 - Low 1 - Later
        Summarywrong tab completion on folder names with spaces wrong tab completion on directory names with spaces
    2016-11-17 mtmiller Release4.0.1-rc1 dev
    2016-03-13 lachlan StatusNeed Info Postponed
    2016-03-07 philipnienhuis Attached File- Added MLr2016a_prel_tabcompletion.png, #36564
    2016-03-07 lachlan Severity3 - Normal 2 - Minor
        Priority5 - Normal 3 - Low
        StatusNone Need Info
        Originator Name Hartmut

    Back to the top

    Powered by Savane 3.14-f13d.
    Corresponding source code