mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Changed how has checks work
This commit is contained in:
parent
788351e178
commit
533ef0856b
5 changed files with 135 additions and 58 deletions
|
@ -37,7 +37,9 @@ namespace IDE
|
||||||
public String mQueuedContent ~ delete _;
|
public String mQueuedContent ~ delete _;
|
||||||
public bool mHadRefusedFileChange;
|
public bool mHadRefusedFileChange;
|
||||||
public bool mFileDeleted;
|
public bool mFileDeleted;
|
||||||
public SourceHash mLoadedHash;
|
|
||||||
|
public MD5Hash mMD5Hash;
|
||||||
|
public SHA256Hash mSHA256Hash;
|
||||||
|
|
||||||
public this()
|
public this()
|
||||||
{
|
{
|
||||||
|
@ -85,8 +87,8 @@ namespace IDE
|
||||||
{
|
{
|
||||||
var editWidgetContent = (SourceEditWidgetContent)mEditWidget.mEditWidgetContent;
|
var editWidgetContent = (SourceEditWidgetContent)mEditWidget.mEditWidgetContent;
|
||||||
mFileDeleted = !editWidgetContent.Reload(mFilePath, mQueuedContent);
|
mFileDeleted = !editWidgetContent.Reload(mFilePath, mQueuedContent);
|
||||||
if (editWidgetContent.mSourceViewPanel.mLoadedHash.GetKind() == mLoadedHash.GetKind())
|
/*if (editWidgetContent.mSourceViewPanel.LoadedHash.GetKind() == mLoadedHash.GetKind())
|
||||||
editWidgetContent.mSourceViewPanel.mLoadedHash = mLoadedHash;
|
editWidgetContent.mSourceViewPanel.LoadedHash = mLoadedHash;*/
|
||||||
mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -137,5 +139,21 @@ namespace IDE
|
||||||
if (--mRefCount == 0)
|
if (--mRefCount == 0)
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void BuildHash(StringView contents)
|
||||||
|
{
|
||||||
|
mMD5Hash = Security.Cryptography.MD5.Hash(.((uint8*)contents.Ptr, contents.Length));
|
||||||
|
mSHA256Hash = Security.Cryptography.SHA256.Hash(.((uint8*)contents.Ptr, contents.Length));
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CheckHash(SourceHash sourceHash)
|
||||||
|
{
|
||||||
|
switch (sourceHash)
|
||||||
|
{
|
||||||
|
case .MD5(let hash): return hash == mMD5Hash;
|
||||||
|
case .SHA256(let hash): return hash == mSHA256Hash;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1233,8 +1233,13 @@ namespace IDE
|
||||||
projectSource.GetFullImportPath(path);
|
projectSource.GetFullImportPath(path);
|
||||||
String text = scope String();
|
String text = scope String();
|
||||||
projectSource.mEditData.mEditWidget.GetText(text);
|
projectSource.mEditData.mEditWidget.GetText(text);
|
||||||
if (!SafeWriteTextFile(path, text, true, projectSource.mEditData.mLineEndingKind))
|
if (!SafeWriteTextFile(path, text, true, projectSource.mEditData.mLineEndingKind, scope (outStr) =>
|
||||||
|
{
|
||||||
|
projectSource.mEditData.BuildHash(outStr);
|
||||||
|
}))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mFileWatcher.OmitFileChange(path, text);
|
mFileWatcher.OmitFileChange(path, text);
|
||||||
projectSource.mEditData.mLastFileTextVersion = projectSource.mEditData.mEditWidget.Content.mData.mCurTextVersionId;
|
projectSource.mEditData.mLastFileTextVersion = projectSource.mEditData.mEditWidget.Content.mData.mCurTextVersionId;
|
||||||
|
@ -1249,7 +1254,7 @@ namespace IDE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SafeWriteTextFile(StringView path, StringView text, bool showErrors = true, LineEndingKind lineEndingKind = .Default)
|
public bool SafeWriteTextFile(StringView path, StringView text, bool showErrors = true, LineEndingKind lineEndingKind = .Default, delegate void(StringView str) strOutDlg = null)
|
||||||
{
|
{
|
||||||
if (mWorkspace.IsSingleFileWorkspace)
|
if (mWorkspace.IsSingleFileWorkspace)
|
||||||
{
|
{
|
||||||
|
@ -1289,6 +1294,9 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (strOutDlg != null)
|
||||||
|
strOutDlg(useText);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1375,8 +1383,13 @@ namespace IDE
|
||||||
String text = scope String();
|
String text = scope String();
|
||||||
sourceViewPanel.mEditWidget.GetText(text);
|
sourceViewPanel.mEditWidget.GetText(text);
|
||||||
|
|
||||||
if (!SafeWriteTextFile(path, text, true, lineEndingKind))
|
if (!SafeWriteTextFile(path, text, true, lineEndingKind, scope (outStr) =>
|
||||||
|
{
|
||||||
|
sourceViewPanel.mEditData.BuildHash(outStr);
|
||||||
|
}))
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
mFileWatcher.OmitFileChange(path, text);
|
mFileWatcher.OmitFileChange(path, text);
|
||||||
if (forcePath == null)
|
if (forcePath == null)
|
||||||
|
@ -5395,7 +5408,7 @@ namespace IDE
|
||||||
return editWidget;
|
return editWidget;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CreateEditDataEditWidget(FileEditData editData, SourceHash.Kind hashKind = .MD5)
|
public bool CreateEditDataEditWidget(FileEditData editData)
|
||||||
{
|
{
|
||||||
if (editData.mEditWidget != null)
|
if (editData.mEditWidget != null)
|
||||||
return true;
|
return true;
|
||||||
|
@ -5430,8 +5443,7 @@ namespace IDE
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
editData.BuildHash(text);
|
||||||
editData.mLoadedHash = SourceHash.Create(hashKind, text);
|
|
||||||
} ) case .Err)
|
} ) case .Err)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -5451,7 +5463,7 @@ namespace IDE
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FileEditData GetEditData(String filePath, bool createEditData = true, bool createEditDataWidget = true, SourceHash.Kind hashKind = .MD5)
|
public FileEditData GetEditData(String filePath, bool createEditData = true, bool createEditDataWidget = true)
|
||||||
{
|
{
|
||||||
FileEditData editData;
|
FileEditData editData;
|
||||||
using (mMonitor.Enter())
|
using (mMonitor.Enter())
|
||||||
|
@ -5471,7 +5483,7 @@ namespace IDE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (createEditDataWidget)
|
if (createEditDataWidget)
|
||||||
CreateEditDataEditWidget(editData, hashKind);
|
CreateEditDataEditWidget(editData);
|
||||||
return editData;
|
return editData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6171,21 +6183,7 @@ namespace IDE
|
||||||
if (hashPos != -1)
|
if (hashPos != -1)
|
||||||
{
|
{
|
||||||
let hashStr = StringView(filePath, hashPos + 1);
|
let hashStr = StringView(filePath, hashPos + 1);
|
||||||
|
hash = SourceHash.Create(hashStr);
|
||||||
if (hashStr.Length == 32)
|
|
||||||
{
|
|
||||||
if (MD5Hash.Parse(hashStr) case .Ok(let parsedHash))
|
|
||||||
{
|
|
||||||
hash = .MD5(parsedHash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (SHA256Hash.Parse(hashStr) case .Ok(let parsedHash))
|
|
||||||
{
|
|
||||||
hash = .SHA256(parsedHash);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
filePath.RemoveToEnd(hashPos);
|
filePath.RemoveToEnd(hashPos);
|
||||||
|
|
||||||
if (frameFlags.HasFlag(.CanLoadOldVersion))
|
if (frameFlags.HasFlag(.CanLoadOldVersion))
|
||||||
|
@ -6267,13 +6265,13 @@ namespace IDE
|
||||||
|
|
||||||
if (sourceViewPanel.mLoadFailed)
|
if (sourceViewPanel.mLoadFailed)
|
||||||
{
|
{
|
||||||
sourceViewPanel.mLoadedHash = hash;
|
sourceViewPanel.mWantHash = hash;
|
||||||
if (loadCmd != null)
|
if (loadCmd != null)
|
||||||
{
|
{
|
||||||
sourceViewPanel.SetLoadCmd(loadCmd);
|
sourceViewPanel.SetLoadCmd(loadCmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((hash != .None) && (hash != sourceViewPanel.mLoadedHash))
|
else if ((hash != .None) && (sourceViewPanel.mEditData != null) && (!sourceViewPanel.mEditData.CheckHash(hash)))
|
||||||
{
|
{
|
||||||
sourceViewPanel.ShowWrongHash();
|
sourceViewPanel.ShowWrongHash();
|
||||||
}
|
}
|
||||||
|
@ -6687,7 +6685,7 @@ namespace IDE
|
||||||
|
|
||||||
void SysKeyDown(KeyDownEvent evt)
|
void SysKeyDown(KeyDownEvent evt)
|
||||||
{
|
{
|
||||||
if (evt.mHandled)
|
if (evt.mHandled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var window = (WidgetWindow)evt.mSender;
|
var window = (WidgetWindow)evt.mSender;
|
||||||
|
@ -11674,10 +11672,7 @@ namespace IDE
|
||||||
editData.mQueuedContent.Clear();
|
editData.mQueuedContent.Clear();
|
||||||
if (LoadTextFile(fileName, editData.mQueuedContent, false, scope() =>
|
if (LoadTextFile(fileName, editData.mQueuedContent, false, scope() =>
|
||||||
{
|
{
|
||||||
if (editData.mLoadedHash.GetKind() != .None)
|
editData.BuildHash(editData.mQueuedContent);
|
||||||
{
|
|
||||||
editData.mLoadedHash = SourceHash.Create(editData.mLoadedHash.GetKind(), editData.mQueuedContent);
|
|
||||||
}
|
|
||||||
}) case .Err(let err))
|
}) case .Err(let err))
|
||||||
{
|
{
|
||||||
if (err case .FileOpenError(.SharingViolation))
|
if (err case .FileOpenError(.SharingViolation))
|
||||||
|
|
|
@ -238,6 +238,7 @@ namespace IDE.ui
|
||||||
|
|
||||||
void SetFile(String fileName, out bool isOld)
|
void SetFile(String fileName, out bool isOld)
|
||||||
{
|
{
|
||||||
|
mSourceHash = .();
|
||||||
isOld = false;
|
isOld = false;
|
||||||
String useFileName = scope String(fileName);
|
String useFileName = scope String(fileName);
|
||||||
if (mAliasFilePath != null)
|
if (mAliasFilePath != null)
|
||||||
|
@ -361,9 +362,13 @@ namespace IDE.ui
|
||||||
IDEApp.sApp.Fail("Unable to locate source");
|
IDEApp.sApp.Fail("Unable to locate source");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#unwarn
|
||||||
var sourceViewPanel = gApp.ShowSourceFileLocation(mSourceFileName, -1, IDEApp.sApp.mWorkspace.GetHighestCompileIdx(), mSourceLine, mSourceColumn, LocatorType.None);
|
var sourceViewPanel = gApp.ShowSourceFileLocation(mSourceFileName, -1, IDEApp.sApp.mWorkspace.GetHighestCompileIdx(), mSourceLine, mSourceColumn, LocatorType.None);
|
||||||
if (sourceViewPanel.mLoadedHash case .None)
|
if (sourceViewPanel.mLoadFailed)
|
||||||
sourceViewPanel.mLoadedHash = mSourceHash; // Set for when we do Auto Find
|
sourceViewPanel.mWantHash = mSourceHash;
|
||||||
|
|
||||||
|
/*if (sourceViewPanel.LoadedHash case .None)
|
||||||
|
sourceViewPanel.LoadedHash = mSourceHash; // Set for when we do Auto Find*/
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SelectLine(int addr, bool jumpToPos)
|
public bool SelectLine(int addr, bool jumpToPos)
|
||||||
|
@ -577,6 +582,10 @@ namespace IDE.ui
|
||||||
lineIdx++;
|
lineIdx++;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'H':
|
||||||
|
{
|
||||||
|
mSourceHash = SourceHash.Create(.(line, 2));
|
||||||
|
}
|
||||||
case 'T':
|
case 'T':
|
||||||
{
|
{
|
||||||
typeId = (int32)SourceElementType.Disassembly_FileName;
|
typeId = (int32)SourceElementType.Disassembly_FileName;
|
||||||
|
@ -1082,7 +1091,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Show(String file, int lineNum, int column)
|
public bool Show(String file, int lineNum, int column)
|
||||||
{
|
{
|
||||||
String addrs = scope String();
|
String addrs = scope String();
|
||||||
IDEApp.sApp.mDebugger.FindCodeAddresses(file, lineNum, column, true, addrs);
|
IDEApp.sApp.mDebugger.FindCodeAddresses(file, lineNum, column, true, addrs);
|
||||||
if (addrs.Length == 0)
|
if (addrs.Length == 0)
|
||||||
|
|
|
@ -3,6 +3,7 @@ using Beefy.theme.dark;
|
||||||
using Beefy.gfx;
|
using Beefy.gfx;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using Beefy.geom;
|
||||||
|
|
||||||
namespace IDE.ui
|
namespace IDE.ui
|
||||||
{
|
{
|
||||||
|
@ -36,6 +37,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
List<KeyEntry> mKeyEntries ~ DeleteContainerAndItems!(_);
|
List<KeyEntry> mKeyEntries ~ DeleteContainerAndItems!(_);
|
||||||
|
bool mHideVSHelper;
|
||||||
|
|
||||||
protected override float TopY
|
protected override float TopY
|
||||||
{
|
{
|
||||||
|
@ -56,6 +58,11 @@ namespace IDE.ui
|
||||||
AddCategoryItem(root, "Compiler");
|
AddCategoryItem(root, "Compiler");
|
||||||
AddCategoryItem(root, "Debugger");
|
AddCategoryItem(root, "Debugger");
|
||||||
AddCategoryItem(root, "Visual Studio");
|
AddCategoryItem(root, "Visual Studio");
|
||||||
|
|
||||||
|
if (gApp.mSettings.mVSSettings.IsConfigured())
|
||||||
|
gApp.mSettings.mVSSettings.SetDefaults();
|
||||||
|
if (gApp.mSettings.mVSSettings.IsConfigured())
|
||||||
|
mHideVSHelper = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopulateEditorOptions()
|
void PopulateEditorOptions()
|
||||||
|
@ -411,6 +418,41 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
CheckForChanges(mPropPages);
|
CheckForChanges(mPropPages);
|
||||||
|
|
||||||
|
if (mPropPage?.mCategoryType == 4)
|
||||||
|
{
|
||||||
|
if (mWidgetWindow.mFocusWidget?.HasParent(mPropPage.mPropertiesListView) == true)
|
||||||
|
{
|
||||||
|
mHideVSHelper = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void DrawAll(Graphics g)
|
||||||
|
{
|
||||||
|
base.DrawAll(g);
|
||||||
|
|
||||||
|
if ((mPropPage?.mCategoryType == 4) && (!mHideVSHelper))
|
||||||
|
{
|
||||||
|
var rect = mPropPage.mPropertiesListView.GetRect();
|
||||||
|
rect.Top += GS!(120);
|
||||||
|
|
||||||
|
rect.Inflate(-GS!(20), -GS!(20));
|
||||||
|
rect.mWidth -= GS!(10);
|
||||||
|
|
||||||
|
g.SetFont(DarkTheme.sDarkTheme.mSmallFont);
|
||||||
|
String helpStr = "NOTE: These settings will be auto-detected if you have Visual Studio 2013 or later installed. You should not need to manually configure these settings.";
|
||||||
|
rect.mHeight = g.mFont.GetWrapHeight(helpStr, rect.mWidth - GS!(40)) + GS!(40);
|
||||||
|
|
||||||
|
using (g.PushClip(0, 0, mWidth, mPropPage.mPropertiesListView.mY + mPropPage.mPropertiesListView.mHeight))
|
||||||
|
{
|
||||||
|
using (g.PushColor(0x80000000))
|
||||||
|
g.FillRect(rect.mX, rect.mY, rect.mWidth, rect.mHeight);
|
||||||
|
|
||||||
|
g.DrawString(helpStr, rect.mX + GS!(20), rect.mY + GS!(20), .Left, rect.mWidth - GS!(40), .Wrap);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,15 +174,15 @@ namespace IDE.ui
|
||||||
void CheckFile(String filePath)
|
void CheckFile(String filePath)
|
||||||
{
|
{
|
||||||
bool hashMatches = true;
|
bool hashMatches = true;
|
||||||
if (!(mSourceViewPanel.mLoadedHash case .None))
|
if (!(mSourceViewPanel.mWantHash case .None))
|
||||||
{
|
{
|
||||||
SourceHash.Kind hashKind = mSourceViewPanel.mLoadedHash.GetKind();
|
SourceHash.Kind hashKind = mSourceViewPanel.mWantHash.GetKind();
|
||||||
|
|
||||||
var buffer = scope String();
|
var buffer = scope String();
|
||||||
SourceHash hash = ?;
|
SourceHash hash = ?;
|
||||||
if (gApp.LoadTextFile(filePath, buffer, true, scope [&] () => { hash = SourceHash.Create(hashKind, buffer); }) case .Ok)
|
if (gApp.LoadTextFile(filePath, buffer, true, scope [&] () => { hash = SourceHash.Create(hashKind, buffer); }) case .Ok)
|
||||||
{
|
{
|
||||||
if (hash != mSourceViewPanel.mLoadedHash)
|
if (hash != mSourceViewPanel.mWantHash)
|
||||||
hashMatches = false;
|
hashMatches = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -244,7 +244,8 @@ namespace IDE.ui
|
||||||
let localPath = scope String();
|
let localPath = scope String();
|
||||||
localPath.Append(localDir);
|
localPath.Append(localDir);
|
||||||
localPath.Append(mFilePath, origDir.Length);
|
localPath.Append(mFilePath, origDir.Length);
|
||||||
CheckFile(localPath);
|
if (File.Exists(localPath))
|
||||||
|
CheckFile(localPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -286,6 +287,26 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static SourceHash Create(StringView hashStr)
|
||||||
|
{
|
||||||
|
if (hashStr.Length == 32)
|
||||||
|
{
|
||||||
|
if (MD5Hash.Parse(hashStr) case .Ok(let parsedHash))
|
||||||
|
{
|
||||||
|
return .MD5(parsedHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (hashStr.Length == 64)
|
||||||
|
{
|
||||||
|
if (SHA256Hash.Parse(hashStr) case .Ok(let parsedHash))
|
||||||
|
{
|
||||||
|
return .SHA256(parsedHash);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return .None;
|
||||||
|
}
|
||||||
|
|
||||||
public static SourceHash Create(Kind kind, StringView str)
|
public static SourceHash Create(Kind kind, StringView str)
|
||||||
{
|
{
|
||||||
switch (kind)
|
switch (kind)
|
||||||
|
@ -354,7 +375,6 @@ namespace IDE.ui
|
||||||
public String mFilePath ~ delete _;
|
public String mFilePath ~ delete _;
|
||||||
public bool mIsBinary;
|
public bool mIsBinary;
|
||||||
public String mAliasFilePath ~ delete _;
|
public String mAliasFilePath ~ delete _;
|
||||||
public SourceHash mLoadedHash;
|
|
||||||
#if IDE_C_SUPPORT
|
#if IDE_C_SUPPORT
|
||||||
public ProjectSource mClangSource; // For headers, an implementing .cpp file
|
public ProjectSource mClangSource; // For headers, an implementing .cpp file
|
||||||
#endif
|
#endif
|
||||||
|
@ -408,6 +428,7 @@ namespace IDE.ui
|
||||||
SourceViewPanel mOldVersionPanel;
|
SourceViewPanel mOldVersionPanel;
|
||||||
SourceViewPanel mCurrentVersionPanel;
|
SourceViewPanel mCurrentVersionPanel;
|
||||||
EditWidgetContent.LineAndColumn? mRequestedLineAndColumn;
|
EditWidgetContent.LineAndColumn? mRequestedLineAndColumn;
|
||||||
|
public SourceHash mWantHash;
|
||||||
|
|
||||||
SourceViewPanel mSplitTopPanel; // This is only set if we are controlling a top panel
|
SourceViewPanel mSplitTopPanel; // This is only set if we are controlling a top panel
|
||||||
PanelSplitter mSplitter;
|
PanelSplitter mSplitter;
|
||||||
|
@ -894,10 +915,7 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
mEditData.mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
mEditData.mLastFileTextVersion = mEditWidget.Content.mData.mCurTextVersionId;
|
||||||
mEditData.mHadRefusedFileChange = false;
|
mEditData.mHadRefusedFileChange = false;
|
||||||
}
|
|
||||||
if (mProjectSource != null)
|
|
||||||
{
|
|
||||||
//mProjectSource.ClearUnsavedData();
|
|
||||||
var editText = scope String();
|
var editText = scope String();
|
||||||
mEditWidget.GetText(editText);
|
mEditWidget.GetText(editText);
|
||||||
using (gApp.mMonitor.Enter())
|
using (gApp.mMonitor.Enter())
|
||||||
|
@ -2783,10 +2801,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SourceHash.Kind hashKind = mLoadedHash.GetKind();
|
useFileEditData = gApp.GetEditData(useFilePath, true, true);
|
||||||
if (hashKind == .None)
|
|
||||||
hashKind = .MD5;
|
|
||||||
useFileEditData = gApp.GetEditData(useFilePath, true, true, hashKind);
|
|
||||||
}
|
}
|
||||||
if (useFileEditData.mEditWidget == null)
|
if (useFileEditData.mEditWidget == null)
|
||||||
useFileEditData = null;
|
useFileEditData = null;
|
||||||
|
@ -2903,7 +2918,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mLoadedHash = useFileEditData.mLoadedHash;
|
//LoadedHash = useFileEditData.mLoadedHash;
|
||||||
|
|
||||||
// Sanity check for when we have the saved data cached already
|
// Sanity check for when we have the saved data cached already
|
||||||
if (useFileEditData.IsFileDeleted())
|
if (useFileEditData.IsFileDeleted())
|
||||||
|
@ -3330,15 +3345,15 @@ namespace IDE.ui
|
||||||
|
|
||||||
void CheckAdjustFile()
|
void CheckAdjustFile()
|
||||||
{
|
{
|
||||||
if (mLoadedHash == .None)
|
if (mEditData == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String text = scope .();
|
String text = scope .();
|
||||||
if (File.ReadAllText(mFilePath, text, true) case .Err)
|
if (File.ReadAllText(mFilePath, text, true) case .Err)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SourceHash textHash = SourceHash.Create(mLoadedHash.GetKind(), text);
|
SourceHash textHash = SourceHash.Create(.MD5, text);
|
||||||
if (textHash == mLoadedHash)
|
if (mEditData.CheckHash(textHash))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (text.Contains('\r'))
|
if (text.Contains('\r'))
|
||||||
|
@ -3349,8 +3364,8 @@ namespace IDE.ui
|
||||||
{
|
{
|
||||||
text.Replace("\n", "\r\n");
|
text.Replace("\n", "\r\n");
|
||||||
}
|
}
|
||||||
textHash = SourceHash.Create(mLoadedHash.GetKind(), text);
|
textHash = SourceHash.Create(.MD5, text);
|
||||||
if (textHash == mLoadedHash)
|
if (mEditData.CheckHash(textHash))
|
||||||
{
|
{
|
||||||
if (File.WriteAllText(mFilePath, text) case .Err)
|
if (File.WriteAllText(mFilePath, text) case .Err)
|
||||||
{
|
{
|
||||||
|
@ -3362,14 +3377,12 @@ namespace IDE.ui
|
||||||
|
|
||||||
void RetryLoad()
|
void RetryLoad()
|
||||||
{
|
{
|
||||||
var prevHash = mLoadedHash;
|
|
||||||
|
|
||||||
Reload();
|
Reload();
|
||||||
if (mRequestedLineAndColumn != null)
|
if (mRequestedLineAndColumn != null)
|
||||||
ShowFileLocation(-1, mRequestedLineAndColumn.mValue.mLine, mRequestedLineAndColumn.mValue.mColumn, .Always);
|
ShowFileLocation(-1, mRequestedLineAndColumn.mValue.mLine, mRequestedLineAndColumn.mValue.mColumn, .Always);
|
||||||
FocusEdit();
|
FocusEdit();
|
||||||
|
|
||||||
if ((!(prevHash case .None)) && (prevHash != mLoadedHash))
|
if ((!(mWantHash case .None)) && (mEditData != null) && (!mEditData.CheckHash(mWantHash)))
|
||||||
ShowWrongHash();
|
ShowWrongHash();
|
||||||
|
|
||||||
if (!mLoadFailed)
|
if (!mLoadFailed)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue