This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
When netbeans crashes or killed, it restores opened files, and they are opened not using project encoding (utf-8) but environment encoding cp1257 on windows, which leads to corruption of texts with urf-8 characters. You can reproduce this, by opening a utf-8 encoded file, and then from task manager selecting Kill process tree, then launch netbeans, it will restore the files and text will be garbled. Sometimes netbeans even shows a warning that the file cannot bet opened using windows-1257 encoding, although project's encoding is different. Product Version: NetBeans IDE 8.0.1 (Build 201408251540) Java: 1.8.0_20; Java HotSpot(TM) 64-Bit Server VM 25.20-b23 Runtime: Java(TM) SE Runtime Environment 1.8.0_20-b26 System: Windows 8 version 6.2 running on amd64; Cp1257; en_GB (nb) User directory: C:\Users\jusurb\AppData\Roaming\NetBeans\8.0.1 Cache directory: C:\Users\jusurb\AppData\Local\NetBeans\Cache\8.0.1
Bug #248599 ("Editor opens UTF-8 files in wrong encoding (causing data loss)") seems to be related to this one.
NB maintains a cross-reference of projects owning file(s) outside the project directory. That cross-reference is saved upon IDE's [regular] exit, so in a case of crash/kill, the data is not saved at all. During the startup, the IDE simply does not know what project the opened file belongs to - unless that project opens.
Svata, possible improvement could be to store last seen encoding associated with file. So, when files are reopened on IDE restart we don't use default encoding, but saved one.
btw, isn't this bug is dup of P1 https://netbeans.org/bugzilla/show_bug.cgi?id=248599?
(In reply to Vladimir Voskresensky from comment #4) > btw, isn't this bug is dup of P1 > https://netbeans.org/bugzilla/show_bug.cgi?id=248599? Not exactly; that one supposes regular exit+start, which saves the file>project cache. The code seems to contain a race I am going to fix. This defect supposes crash/kill scenario, I think it should be handled separately - and possibly it's not even P1, since in the anomalous situation the user can simply reopen the file, or recover the good state from local history and/or VCS.
Moving to projects -- there's a little what can be done on Editor's side: a/ wait for all projects to load: access to all editors would be blocked during the "Opening projects..." sequence, which may be seen as a perf/usability issue. b/ load documents using the best knowledge at the time, reload opened editors after all project load, or warn the user if the text has been alredy modified. Drawbacks: Documents are already loaded, might be programatically processed (and then saved broken). Probably requires an additional API. c/ do not open any files after crash :)
BTW - the real issue is that FileOwnerQuery provides bad results (= identifies a file as non-project) while projects are opening. Potentially more features than just encoding/loading editor are affected, but the results are not cached so firmly; i.e. parsing will produce correct results once the projects have been loaded and old parser.result is thrown away.
This old bug may not be relevant anymore. If you can still reproduce it in 8.2 development builds please reopen this issue. Thanks for your cooperation, NetBeans IDE 8.2 Release Boss
Still valid in 8.2 dev Product Version: NetBeans IDE Dev (Build 201607100002)