mirror of https://github.com/buggins/dlangide.git
missing source file opening - error handling fixes for #323
This commit is contained in:
parent
12aa890d71
commit
a4f0f07112
|
@ -140,7 +140,8 @@ class DSourceEdit : SourceEdit, EditableContentMarksChangeListener {
|
||||||
override bool load(string fn) {
|
override bool load(string fn) {
|
||||||
_projectSourceFile = null;
|
_projectSourceFile = null;
|
||||||
bool res = super.load(fn);
|
bool res = super.load(fn);
|
||||||
setSyntaxSupport();
|
if (res)
|
||||||
|
setSyntaxSupport();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -413,6 +413,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
bool openSourceFile(string filename, ProjectSourceFile file = null, bool activate = true) {
|
bool openSourceFile(string filename, ProjectSourceFile file = null, bool activate = true) {
|
||||||
if (!file && !filename)
|
if (!file && !filename)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
filename ~= ".invalid";
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
file = _wsPanel.findSourceFileItem(filename, false);
|
file = _wsPanel.findSourceFileItem(filename, false);
|
||||||
|
|
||||||
|
@ -430,7 +433,9 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
} else {
|
} else {
|
||||||
// open new file
|
// open new file
|
||||||
DSourceEdit editor = new DSourceEdit(filename);
|
DSourceEdit editor = new DSourceEdit(filename);
|
||||||
|
Log.d("trying to open source file ", filename);
|
||||||
if (file ? editor.load(file) : editor.load(filename)) {
|
if (file ? editor.load(file) : editor.load(filename)) {
|
||||||
|
Log.d("file ", filename, " is opened ok");
|
||||||
_tabs.addTab(editor, toUTF32(baseName(filename)), null, true, filename.toUTF32);
|
_tabs.addTab(editor, toUTF32(baseName(filename)), null, true, filename.toUTF32);
|
||||||
index = _tabs.tabIndex(filename);
|
index = _tabs.tabIndex(filename);
|
||||||
TabItem tab = _tabs.tab(filename);
|
TabItem tab = _tabs.tab(filename);
|
||||||
|
@ -450,9 +455,10 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
editor.editorTool = new DefaultEditorTool(this);
|
editor.editorTool = new DefaultEditorTool(this);
|
||||||
_tabs.layout(_tabs.pos);
|
_tabs.layout(_tabs.pos);
|
||||||
} else {
|
} else {
|
||||||
|
Log.d("file ", filename, " cannot be opened");
|
||||||
destroy(editor);
|
destroy(editor);
|
||||||
if (window)
|
if (window)
|
||||||
window.showMessageBox(UIString.fromId("ERROR_OPEN_FILE"c), UIString.fromId("ERROR_OPENING_FILE"c) ~ " " ~ toUTF32(file.filename));
|
window.showMessageBox(UIString.fromId("ERROR_OPEN_FILE"c), UIString.fromId("ERROR_OPENING_FILE"c) ~ " " ~ toUTF32(filename));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1534,8 +1540,12 @@ class IDEFrame : AppFrame, ProgramExecutionStatusListener, BreakpointListChangeL
|
||||||
if (openSourceFile(filename))
|
if (openSourceFile(filename))
|
||||||
{
|
{
|
||||||
auto index = _tabs.tabIndex(filename);
|
auto index = _tabs.tabIndex(filename);
|
||||||
|
if (index < 0)
|
||||||
|
continue;
|
||||||
// file is opened in tab
|
// file is opened in tab
|
||||||
auto source = cast(DSourceEdit)_tabs.tabBody(filename);
|
auto source = cast(DSourceEdit)_tabs.tabBody(filename);
|
||||||
|
if (!source)
|
||||||
|
continue;
|
||||||
// Caret position
|
// Caret position
|
||||||
source.setCaretPos(column, row, true, true);
|
source.setCaretPos(column, row, true, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue