Bug 142228 - [EditorMgmt] Don't expect File->Open to invoke system editor
Summary: [EditorMgmt] Don't expect File->Open to invoke system editor
Status: CLOSED DUPLICATE of bug 90292
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 normal with 3 votes (vote)
Target Milestone: 4.6 M5   Edit
Assignee: Platform UI Triaged CLA
QA Contact:
URL:
Whiteboard:
Keywords: helpwanted
: 53359 178011 216615 224702 232345 303021 421805 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-05-17 10:37 EDT by Neil Rickards CLA
Modified: 2016-01-15 08:12 EST (History)
21 users (show)

See Also:
daniel_megert: pmc_approved-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Neil Rickards CLA 2006-05-17 10:37:23 EDT
I don't yet have the CDT installed.  If I hit "File" -> "Open File..." and select a .c file my system editor (Visual Studio) is launched.

I would not expect File -> Open to launch another app in any circumstance.  In this case I would expect a basic text editor.  A hex editor might be more appropriate if the file is detected as binary
Comment 1 Dani Megert CLA 2008-05-08 02:50:56 EDT
*** Bug 178011 has been marked as a duplicate of this bug. ***
Comment 2 Dani Megert CLA 2008-05-08 02:51:03 EDT
*** Bug 216615 has been marked as a duplicate of this bug. ***
Comment 3 Dani Megert CLA 2008-05-08 02:58:10 EDT
*** Bug 224702 has been marked as a duplicate of this bug. ***
Comment 4 Susan McCourt CLA 2009-07-09 19:08:50 EDT
As per http://wiki.eclipse.org/Platform_UI/Bug_Triage_Change_2009
Comment 5 Boris Bokowski CLA 2009-11-17 13:02:26 EST
Remy is now responsible for watching the [EditorMgmt] component area.
Comment 6 Paul Webster CLA 2010-02-17 08:03:16 EST
*** Bug 303021 has been marked as a duplicate of this bug. ***
Comment 7 Dani Megert CLA 2011-07-04 03:59:03 EDT
*** Bug 53359 has been marked as a duplicate of this bug. ***
Comment 8 Markus Keller CLA 2011-07-04 07:02:35 EDT
Before a file is opened with the System Editor, we should ask the user by default.

The dialog should have a checkbox "Always use the System Editor for this file type". If checked, the file type should be added to the "File Associations" preference page and the System Editor should be assigned as default editor.

If a file type has the System Editor configured as "associated editor", but it's not the default editor, then the dialog should also not be shown any more if the user opens a file with Open With > System Editor.
Comment 9 Martin Oberhuber CLA 2011-07-04 11:29:18 EDT
I like the idea of configuring file associations on the fly, by asking back for file associations not yet known.

The dialog should be capable of making a file association with any editor (internal or external), not only with the System Editor (like Open With ... Other).

I'm not yet sure to what extent the "Default Open Behavior" should be a Product Setting. For products that behave like an editor or IDE, end users would probably expect opening files in the internal editor by default.

And, I'm not yet sure how to handle file types that don't have an extension (like many UNIX shellscripts).
Comment 10 Oleg Besedin CLA 2011-07-07 14:41:52 EDT
(In reply to comment #8)
> Before a file is opened with the System Editor, we should ask the user by
> default.

Hmm... If we are going to change it after all those years, I'd prefer a Firefox-style solution where some file extensions are asked, and some are opened without asking, and there is an option to change it.

- For ".c", ".cpp", ".project" files, in other words, well-knows file types that cause issues like what described in the comment 0 we should ask on the first file opening

- For ".jpg", ".wmv", and such we should open system editor, if any

- We should have both programmatic and UI ways to change the preferred behavior.
Comment 11 Markus Keller CLA 2011-07-10 18:40:36 EDT
(In reply to comment #10)
All these concerns are met with the proposal in the rest of comment 8, where the "System Editor" is only used after it got an explicit file association. File associations are already contributable today.

See bug 46297 about file types without extension.
Comment 12 Martin Oberhuber CLA 2012-01-16 11:02:08 EST
*** Bug 368641 has been marked as a duplicate of this bug. ***
Comment 13 Dani Megert CLA 2013-11-18 11:12:27 EST
*** Bug 421805 has been marked as a duplicate of this bug. ***
Comment 14 Mickael Istria CLA 2013-11-19 05:00:37 EST
The general issue here seems to be that by default, the platform provide a very minimal set of defined content-type, so that most filetypes ends up by being unknown so open with External Editor. Is this interpretation correct?
If so, what about creating a contenttype registry plugin inside platform which would define as many content-types as it can so most known fileformat who can be opened with Text Editor would actually be opened with Eclipse Text Editor ?
Comment 15 Dani Megert CLA 2014-02-11 11:13:07 EST
*** Bug 232345 has been marked as a duplicate of this bug. ***
Comment 16 Andre Bossert CLA 2014-02-13 07:07:26 EST
From my point of view the solution should be same for DnD and "Open File...".

See my proposed solution from duplicate
https://bugs.eclipse.org/bugs/show_bug.cgi?id=232345#c16

...
In "other" editors the fall-back is done by using text editor or asking you what editor should be opened (also external). Our developers are expecting the same from eclipse. The problem is: you cannot just open an unknown file with eclipse text editor or hex-editor (javahex-plugin). 

My offer is to provide checkbox for this feature (General->Editors):
[] Prompt to select editor if opening unknown file type

If this checkbox is selected, eclipse should show the same dialog like "Open With -> Other".
...
Comment 17 Kaloyan Raev CLA 2015-04-22 02:31:45 EDT
I created a small plugin [1] that overrides the default behavior of the platform and opens text file of unknown type in the plain text editor of Eclipse instead in an external editor.

[1] https://github.com/eclipselabs/default-text-editor
Comment 18 Eclipse Genie CLA 2015-04-23 08:53:30 EDT
New Gerrit change created: https://git.eclipse.org/r/46341
Comment 19 Kaloyan Raev CLA 2015-04-23 08:58:49 EDT
I pushed a Gerrit patch that contributes the implementation of the plugin plus a preference to enable and disable the overriding of the default editor. The new preference is in the General > Editors page - a check box with label "Open unknown text files in the text editor".
Comment 20 Dani Megert CLA 2015-04-23 09:25:42 EDT
I will have to take a closer look. I'm not sure that we want to make that change so late in the game but rather postpone it to 4.6. If we decide to take it for 4.5 then the default must be like in 4.4.
Comment 21 Lars Vogel CLA 2015-04-23 09:29:16 EDT
(In reply to Dani Megert from comment #20)
> I will have to take a closer look. I'm not sure that we want to make that
> change so late in the game but rather postpone it to 4.6. If we decide to
> take it for 4.5 then the default must be like in 4.4.

+1 from my side to include it in 4.5. If the default stays as in 4.4 we should  adjust it early in 4.6.
Comment 22 Andrey Loskutov CLA 2015-04-25 18:11:18 EDT
(In reply to Lars Vogel from comment #21)
> (In reply to Dani Megert from comment #20)
> > I will have to take a closer look. I'm not sure that we want to make that
> > change so late in the game but rather postpone it to 4.6. If we decide to
> > take it for 4.5 then the default must be like in 4.4.
> 
> +1 from my side to include it in 4.5. If the default stays as in 4.4 we
> should  adjust it early in 4.6.

+1 from me too for 4.5. I did the review, after few requested changes are fixed I think the patch could be integrated into 4.5 (the default would be like in 4.4) but we need PMC approval since a new constant is added to the IDE class.
Comment 23 Andrey Loskutov CLA 2015-04-26 15:18:48 EDT
Current contribution state (https://git.eclipse.org/r/46341) doesn't allow to be submitted for 4.5, but I highly encourage Kaloyan to work towards 4.6 integration, see review comments.
Comment 24 Dani Megert CLA 2015-04-27 05:59:40 EDT
(In reply to Andrey Loskutov from comment #23)
> Current contribution state (https://git.eclipse.org/r/46341) doesn't allow
> to be submitted for 4.5, but I highly encourage Kaloyan to work towards 4.6
> integration, see review comments.

+1.
Comment 25 Kaloyan Raev CLA 2015-04-27 10:13:40 EDT
Thanks for the feedback!

I will submit a new patch set soon with the suggested changes. Since we now target this for 4.6 instead of 4.5, I guess I should not switch this feature off by default, right?

Regarding, improving the TextFileDetector to be more reliable in detecting text vs binary files there a few possible options.

1. Have a predefined list of known file extensions for binary files (e.g. PDF, ZIP, PNG, etc.) and another list of known file extensions for text files (e.g. TXT, JAVA, HTML, XML, etc.). So, first we try matching the file extension of the tested file with these to lists, and only if there is no much to try to test the file content with the ICU CharsetDetector.

2. Try to detect magic numbers in the file content like the Unix file command [1] does. There is a Java library [2] that does this using the magic number definition from the Unix file command. If no match then use the ICU CharsetDetector.

We can use either of the above, or even a combination of both. However, please note that most probably we will never reach a perfect state of detecting if a file is binary or text. For some file types it is quite debatable. For example, are SVG files text or binary? It's an image file, but it's content is XML-based. So, if I double click on an SVG file and the Eclipse installation does not have an associated editor for it, should it be opened with the internal text editor showing the XML content, or should it be opened with an external system editor/viewer showing the image? There are other file types like this.
Comment 26 Kaloyan Raev CLA 2015-04-27 10:16:42 EDT
I forgot to add the bookmarks.

[1] http://linux.die.net/man/1/file
[2] https://github.com/j256/simplemagic
Comment 27 Dani Megert CLA 2015-04-27 11:53:40 EDT
(In reply to Kaloyan Raev from comment #25)
> Thanks for the feedback!
> 
> I will submit a new patch set soon with the suggested changes. Since we now
> target this for 4.6 instead of 4.5, I guess I should not switch this feature
> off by default, right?
> 
> Regarding, improving the TextFileDetector to be more reliable in detecting
> text vs binary files there a few possible options.
> 
> 1. Have a predefined list of known file extensions for binary files (e.g.
> PDF, ZIP, PNG, etc.) and another list of known file extensions for text
> files (e.g. TXT, JAVA, HTML, XML, etc.). So, first we try matching the file
> extension of the tested file with these to lists, and only if there is no
> much to try to test the file content with the ICU CharsetDetector.
> 
> 2. Try to detect magic numbers in the file content like the Unix file
> command [1] does. There is a Java library [2] that does this using the magic
> number definition from the Unix file command. If no match then use the ICU
> CharsetDetector.
> 
> We can use either of the above, or even a combination of both. However,
> please note that most probably we will never reach a perfect state of
> detecting if a file is binary or text. For some file types it is quite
> debatable. For example, are SVG files text or binary? It's an image file,
> but it's content is XML-based. So, if I double click on an SVG file and the
> Eclipse installation does not have an associated editor for it, should it be
> opened with the internal text editor showing the XML content, or should it
> be opened with an external system editor/viewer showing the image? There are
> other file types like this.


I'm not a fan of that approach. We do not want to contribute content types in the platform for which we don't offer support. E.g. WTP will provide content types for XML, HTML etc. Also, we do not need new preferences.

Comment 8 describes the correct fix for this problem.
Comment 28 Kaloyan Raev CLA 2016-01-05 05:31:13 EST
I believe the solution contributed to bug 90292 covers this bug too and we can close it as duplicated.
Comment 29 Andrey Loskutov CLA 2016-01-05 05:33:33 EST
Yep.

*** This bug has been marked as a duplicate of bug 90292 ***