mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 20:42:21 +02:00
Made workspace user file try to use workspace-relative paths
This commit is contained in:
parent
10da44e341
commit
980132c3cc
4 changed files with 77 additions and 26 deletions
|
@ -54,6 +54,11 @@ namespace System.IO
|
|||
|
||||
}
|
||||
|
||||
public static bool IsDirectorySeparatorChar(char8 c)
|
||||
{
|
||||
return (c == DirectorySeparatorChar) || (c == AltDirectorySeparatorChar);
|
||||
}
|
||||
|
||||
public static void ChangeExtension(StringView path, StringView ext, String outPath)
|
||||
{
|
||||
if (path.IsNull)
|
||||
|
|
|
@ -1708,7 +1708,11 @@ namespace IDE
|
|||
using (sd.CreateArray("RecentFilesList"))
|
||||
{
|
||||
for (var recentFile in mRecentlyDisplayedFiles)
|
||||
sd.Add(recentFile);
|
||||
{
|
||||
String relPath = scope .();
|
||||
mWorkspace.GetWorkspaceRelativePath(recentFile, relPath);
|
||||
sd.Add(relPath);
|
||||
}
|
||||
}
|
||||
|
||||
using (sd.CreateArray("Breakpoints"))
|
||||
|
@ -1721,7 +1725,9 @@ namespace IDE
|
|||
{
|
||||
if (breakpoint.mFileName != null)
|
||||
{
|
||||
sd.Add("File", breakpoint.mFileName);
|
||||
String relPath = scope .();
|
||||
mWorkspace.GetWorkspaceRelativePath(breakpoint.mFileName, relPath);
|
||||
sd.Add("File", relPath);
|
||||
sd.Add("Line", breakpoint.mLineNum);
|
||||
sd.Add("Column", breakpoint.mColumn);
|
||||
if (breakpoint.mInstrOffset != -1)
|
||||
|
@ -1755,7 +1761,9 @@ namespace IDE
|
|||
{
|
||||
using (sd.CreateObject())
|
||||
{
|
||||
sd.Add("File", bookmark.mFileName);
|
||||
String relPath = scope .();
|
||||
mWorkspace.GetWorkspaceRelativePath(bookmark.mFileName, relPath);
|
||||
sd.Add("File", relPath);
|
||||
sd.Add("Line", bookmark.mLineNum);
|
||||
sd.Add("Column", bookmark.mColumn);
|
||||
}
|
||||
|
@ -2907,17 +2915,21 @@ namespace IDE
|
|||
DeleteAndClearItems!(mRecentlyDisplayedFiles);
|
||||
for (data.Enumerate("RecentFilesList"))
|
||||
{
|
||||
String fileStr = new String();
|
||||
data.GetCurString(fileStr);
|
||||
IDEUtils.FixFilePath(fileStr);
|
||||
mRecentlyDisplayedFiles.Add(fileStr);
|
||||
String relPath = scope String();
|
||||
data.GetCurString(relPath);
|
||||
IDEUtils.FixFilePath(relPath);
|
||||
String absPath = new String();
|
||||
mWorkspace.GetWorkspaceAbsPath(relPath, absPath);
|
||||
mRecentlyDisplayedFiles.Add(absPath);
|
||||
}
|
||||
|
||||
for (var _breakpoint in data.Enumerate("Breakpoints"))
|
||||
{
|
||||
String fileName = scope String();
|
||||
data.GetString("File", fileName);
|
||||
IDEUtils.FixFilePath(fileName);
|
||||
String relPath = scope String();
|
||||
data.GetString("File", relPath);
|
||||
IDEUtils.FixFilePath(relPath);
|
||||
String absPath = scope String();
|
||||
mWorkspace.GetWorkspaceAbsPath(relPath, absPath);
|
||||
int32 lineNum = data.GetInt("Line");
|
||||
int32 column = data.GetInt("Column");
|
||||
int32 instrOffset = data.GetInt("InstrOffset", -1);
|
||||
|
@ -2926,8 +2938,8 @@ namespace IDE
|
|||
Breakpoint breakpoint = null;
|
||||
if (memoryWatchExpression.Length > 0)
|
||||
breakpoint = mDebugger.CreateMemoryBreakpoint(memoryWatchExpression, (int)0, 0, null);
|
||||
else if (fileName.Length > 0)
|
||||
breakpoint = mDebugger.CreateBreakpoint(fileName, lineNum, column, instrOffset);
|
||||
else if (absPath.Length > 0)
|
||||
breakpoint = mDebugger.CreateBreakpoint(absPath, lineNum, column, instrOffset);
|
||||
else
|
||||
{
|
||||
String symbol = scope .();
|
||||
|
@ -2961,12 +2973,14 @@ namespace IDE
|
|||
|
||||
for (var _bookmark in data.Enumerate("Bookmarks"))
|
||||
{
|
||||
String fileName = scope String();
|
||||
data.GetString("File", fileName);
|
||||
IDEUtils.FixFilePath(fileName);
|
||||
String relPath = scope String();
|
||||
data.GetString("File", relPath);
|
||||
IDEUtils.FixFilePath(relPath);
|
||||
String absPath = scope String();
|
||||
mWorkspace.GetWorkspaceAbsPath(relPath, absPath);
|
||||
int32 lineNum = data.GetInt("Line");
|
||||
int32 column = data.GetInt("Column");
|
||||
mBookmarkManager.CreateBookmark(fileName, lineNum, column);
|
||||
mBookmarkManager.CreateBookmark(absPath, lineNum, column);
|
||||
}
|
||||
|
||||
for (var referenceId in data.Enumerate("DebuggerDisplayTypes"))
|
||||
|
|
|
@ -8,6 +8,7 @@ using System.Diagnostics;
|
|||
using System.Threading;
|
||||
using IDE.Util;
|
||||
using IDE.util;
|
||||
using System.IO;
|
||||
|
||||
namespace IDE
|
||||
{
|
||||
|
@ -494,6 +495,25 @@ namespace IDE
|
|||
return options;
|
||||
}
|
||||
|
||||
public void GetWorkspaceRelativePath(StringView inAbsPath, String outRelPath)
|
||||
{
|
||||
if ((inAbsPath.Length > mDir.Length) &&
|
||||
(Path.Equals(.(inAbsPath, 0, mDir.Length), mDir)) &&
|
||||
(Path.IsDirectorySeparatorChar(inAbsPath[mDir.Length])))
|
||||
{
|
||||
outRelPath.Append(StringView(inAbsPath, mDir.Length + 1));
|
||||
}
|
||||
else
|
||||
outRelPath.Append(inAbsPath);
|
||||
}
|
||||
|
||||
public void GetWorkspaceAbsPath(StringView inRelPath, String outAbsPath)
|
||||
{
|
||||
if (inRelPath.IsEmpty)
|
||||
return;
|
||||
Path.GetAbsolutePath(inRelPath, mDir, outAbsPath);
|
||||
}
|
||||
|
||||
public void Serialize(StructuredData data)
|
||||
{
|
||||
void WriteStrings(String name, List<String> strs)
|
||||
|
|
|
@ -678,9 +678,15 @@ namespace IDE.ui
|
|||
return;
|
||||
|
||||
data.Add("Type", "SourceViewPanel");
|
||||
data.Add("FilePath", mFilePath);
|
||||
String relPath = scope String();
|
||||
gApp.mWorkspace.GetWorkspaceRelativePath(mFilePath, relPath);
|
||||
data.Add("FilePath", relPath);
|
||||
if (mAliasFilePath != null)
|
||||
data.Add("AliasFilePath", mAliasFilePath);
|
||||
{
|
||||
String relAliasPath = scope .();
|
||||
gApp.mWorkspace.GetWorkspaceRelativePath(mAliasFilePath, relAliasPath);
|
||||
data.Add("AliasFilePath", relAliasPath);
|
||||
}
|
||||
data.ConditionalAdd("CursorPos", mEditWidget.Content.CursorTextPos, 0);
|
||||
data.ConditionalAdd("VertPos", mEditWidget.mVertScrollbar.mContentPos, 0);
|
||||
if (mProjectSource != null)
|
||||
|
@ -691,15 +697,21 @@ namespace IDE.ui
|
|||
{
|
||||
base.Deserialize(data);
|
||||
|
||||
String filePath = scope String();
|
||||
data.GetString("FilePath", filePath);
|
||||
String relFilePath = scope String();
|
||||
data.GetString("FilePath", relFilePath);
|
||||
String absFilePath = scope String();
|
||||
gApp.mWorkspace.GetWorkspaceAbsPath(relFilePath, absFilePath);
|
||||
|
||||
String projectName = scope String();
|
||||
data.GetString("ProjectName", projectName);
|
||||
|
||||
var aliasFilePath = scope String();
|
||||
data.GetString("AliasFilePath", aliasFilePath);
|
||||
if (!aliasFilePath.IsEmpty)
|
||||
mAliasFilePath = new String(aliasFilePath);
|
||||
var relAliasFilePath = scope String();
|
||||
data.GetString("AliasFilePath", relAliasFilePath);
|
||||
if (!relAliasFilePath.IsEmpty)
|
||||
{
|
||||
mAliasFilePath = new String();
|
||||
gApp.mWorkspace.GetWorkspaceAbsPath(relAliasFilePath, mAliasFilePath);
|
||||
}
|
||||
|
||||
bool foundProjectSource = false;
|
||||
if (projectName != null)
|
||||
|
@ -708,7 +720,7 @@ namespace IDE.ui
|
|||
if (project != null)
|
||||
{
|
||||
String relPath = scope String();
|
||||
project.GetProjectRelPath(filePath, relPath);
|
||||
project.GetProjectRelPath(absFilePath, relPath);
|
||||
var projectItem = IDEApp.sApp.FindProjectItem(project.mRootFolder, relPath);
|
||||
if (projectItem != null)
|
||||
{
|
||||
|
@ -721,7 +733,7 @@ namespace IDE.ui
|
|||
|
||||
if (!foundProjectSource)
|
||||
{
|
||||
if (!Show(filePath, true))
|
||||
if (!Show(absFilePath, true))
|
||||
return false;
|
||||
}
|
||||
int32 cursorPos = data.GetInt("CursorPos");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue