unixwork / xnedit

A fast and classic X11 text editor, based on NEdit, with full unicode support and antialiased text rendering.
Other
83 stars 11 forks source link

Open Selected with relative path #107

Open cblc opened 1 year ago

cblc commented 1 year ago

The Open Selected option in the File menu works fine only when the file to be opened is in the same directory as the file being edited, or when the full path is specified. But if you have it with relative path (which can happen for some included files in source code), it doesn't work. At least on MacOS, but I assume this will be the case for all the systems. I think it would be a nice addition to have relative paths working.

cblc commented 1 year ago

By the way, I believe that paths with spaces don't work either in Open Selected. Now that I say this, I suppose you apply Unicode normalization to file names and paths before opening files (because for example on MacOS I remember that only one normalization of Unicode works). I didn't experience any problems with this (I typed file names with accents, selected them, and the right files were opened), I'm just reminding that this can be relevant.

unixwork commented 1 year ago

I can't reproduce this problem.

Example:

  1. open xnedit source file source/nedit.c
  2. select ../util/misc.h on line 53
  3. File -> Open Selected

This opens the file misc.h without any problem.

Does this work on your system?

cblc commented 1 year ago

Now it works. I don't understand 😮 Maybe it's related to xnc: yesterday I created a Finder service so that I can select several files in Finder, press a keyboard shortcut, and open the selected files in XNEdit. I used xnc so that all selected files are opened in the same XNEdit window. Very nice feature, because it makes the need of drag and drop superfluous.

BTW, are you interested in this feature? I can explain to you how to do it if you don't know.

cblc commented 1 year ago

You can disregard the original claim: actually the relative path was wrong in the file that I was editing, so no wonder that it didn't work. Anyway, I think that filenames and paths with spaces don't work (for Open Selected, I mean). Do they work for you?

unixwork commented 1 year ago

I can confirm that it doesn't work with spaces in file names. For some reason this is intentional, there is specific code to remove whitespace before trying to open the file.

The whole "Open Selected" feature is more complex than I thought. For example it can expand ~ to the home directory or it can understand C include syntax. I have to look into this a bit more before I can decide how to fix this.

cblc commented 1 year ago

No worries. You can give very, very low priority to this. At least for me, I never use files with whitespace for source code files, for obvious reasons. It just came out because I wanted to test how well the Open Selected feature behaved, but I think it's really powerful like it is. Maybe skipping whitespace had a purpose, perhaps being able to open several files separated by whitespace? I don't know.