mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 03:52:19 +02:00
Made using/pragma fixits no long focus on change
This commit is contained in:
parent
97fd278e07
commit
709b337617
6 changed files with 31 additions and 10 deletions
|
@ -759,7 +759,7 @@ namespace Beefy.theme.dark
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void CheckRecordScrollTop()
|
public void CheckRecordScrollTop(bool force = false)
|
||||||
{
|
{
|
||||||
if (mWantsCheckScrollPosition)
|
if (mWantsCheckScrollPosition)
|
||||||
{
|
{
|
||||||
|
@ -784,7 +784,7 @@ namespace Beefy.theme.dark
|
||||||
mWantsCheckScrollPosition = false;
|
mWantsCheckScrollPosition = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mEditWidget.mHasFocus)
|
if ((mEditWidget.mHasFocus) && (!force))
|
||||||
{
|
{
|
||||||
mTopCharId = -1;
|
mTopCharId = -1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -941,8 +941,8 @@ namespace Beefy.widgets
|
||||||
{
|
{
|
||||||
#unwarn
|
#unwarn
|
||||||
int cursorPos = CursorTextPos;
|
int cursorPos = CursorTextPos;
|
||||||
if (mCursorTextPos >= index)
|
if (cursorPos >= index)
|
||||||
mCursorTextPos = Math.Clamp(mCursorTextPos + (int32)ofs, 0, mData.mTextLength + 1);
|
CursorTextPos = Math.Clamp(mCursorTextPos + (int32)ofs, 0, mData.mTextLength + 1);
|
||||||
if (HasSelection())
|
if (HasSelection())
|
||||||
{
|
{
|
||||||
if (((ofs > 0) && (mSelection.Value.mStartPos >= index)) ||
|
if (((ofs > 0) && (mSelection.Value.mStartPos >= index)) ||
|
||||||
|
|
|
@ -2287,17 +2287,22 @@ namespace IDE.ui
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var targetSourceEditWidgetContent = mTargetEditWidget.Content as SourceEditWidgetContent;
|
||||||
|
var sourceEditWidgetContent = targetSourceEditWidgetContent;
|
||||||
|
var prevCursorPosition = sourceEditWidgetContent.CursorTextPos;
|
||||||
|
var prevScrollPos = mTargetEditWidget.mVertPos.mDest;
|
||||||
|
|
||||||
UndoBatchStart undoBatchStart = null;
|
UndoBatchStart undoBatchStart = null;
|
||||||
|
|
||||||
var parts = String.StackSplit!(data, '|');
|
var parts = String.StackSplit!(data, '|');
|
||||||
|
String fixitKind = parts[0];
|
||||||
String fixitFileName = parts[1];
|
String fixitFileName = parts[1];
|
||||||
SourceViewPanel sourceViewPanel = IDEApp.sApp.ShowSourceFile(fixitFileName);
|
SourceViewPanel sourceViewPanel = IDEApp.sApp.ShowSourceFile(fixitFileName);
|
||||||
|
bool focusChange = !fixitKind.StartsWith(".");
|
||||||
|
|
||||||
var targetSourceEditWidgetContent = mTargetEditWidget.Content as SourceEditWidgetContent;
|
|
||||||
var historyEntry = targetSourceEditWidgetContent.RecordHistoryLocation();
|
var historyEntry = targetSourceEditWidgetContent.RecordHistoryLocation();
|
||||||
historyEntry.mNoMerge = true;
|
historyEntry.mNoMerge = true;
|
||||||
|
|
||||||
var sourceEditWidgetContent = targetSourceEditWidgetContent;
|
|
||||||
if (sourceEditWidgetContent.mSourceViewPanel != sourceViewPanel)
|
if (sourceEditWidgetContent.mSourceViewPanel != sourceViewPanel)
|
||||||
{
|
{
|
||||||
sourceEditWidgetContent = (SourceEditWidgetContent)sourceViewPanel.GetActivePanel().EditWidget.mEditWidgetContent;
|
sourceEditWidgetContent = (SourceEditWidgetContent)sourceViewPanel.GetActivePanel().EditWidget.mEditWidgetContent;
|
||||||
|
@ -2305,6 +2310,11 @@ namespace IDE.ui
|
||||||
sourceEditWidgetContent.mData.mUndoManager.Add(undoBatchStart);
|
sourceEditWidgetContent.mData.mUndoManager.Add(undoBatchStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!focusChange)
|
||||||
|
{
|
||||||
|
sourceEditWidgetContent.CheckRecordScrollTop(true);
|
||||||
|
}
|
||||||
|
|
||||||
int32 fixitIdx = 0;
|
int32 fixitIdx = 0;
|
||||||
int32 fixitLen = 0;
|
int32 fixitLen = 0;
|
||||||
StringView fixitLocStr = parts[2];
|
StringView fixitLocStr = parts[2];
|
||||||
|
@ -2325,6 +2335,8 @@ namespace IDE.ui
|
||||||
else
|
else
|
||||||
fixitIdx = int32.Parse(fixitLocStr).GetValueOrDefault();
|
fixitIdx = int32.Parse(fixitLocStr).GetValueOrDefault();
|
||||||
|
|
||||||
|
int prevTextLength = sourceEditWidgetContent.mData.mTextLength;
|
||||||
|
|
||||||
int insertCount = 0;
|
int insertCount = 0;
|
||||||
int dataIdx = 3;
|
int dataIdx = 3;
|
||||||
|
|
||||||
|
@ -2358,6 +2370,7 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceEditWidgetContent.CursorTextPos = fixitIdx;
|
sourceEditWidgetContent.CursorTextPos = fixitIdx;
|
||||||
|
if (focusChange)
|
||||||
sourceEditWidgetContent.EnsureCursorVisible(true, true);
|
sourceEditWidgetContent.EnsureCursorVisible(true, true);
|
||||||
|
|
||||||
if (fixitLen > 0)
|
if (fixitLen > 0)
|
||||||
|
@ -2377,6 +2390,14 @@ namespace IDE.ui
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!focusChange)
|
||||||
|
{
|
||||||
|
mTargetEditWidget.VertScrollTo(prevScrollPos, true);
|
||||||
|
sourceEditWidgetContent.CursorTextPos = prevCursorPosition;
|
||||||
|
int addedSize = sourceEditWidgetContent.mData.mTextLength - prevTextLength;
|
||||||
|
sourceEditWidgetContent.[Friend]AdjustCursorsAfterExternalEdit(fixitIdx, addedSize);
|
||||||
|
}
|
||||||
|
|
||||||
if (historyEntry != null)
|
if (historyEntry != null)
|
||||||
{
|
{
|
||||||
// Make sure when we go back that we'll go back to the insert position
|
// Make sure when we go back that we'll go back to the insert position
|
||||||
|
|
|
@ -3267,7 +3267,7 @@ void BfAutoComplete::FixitAddNamespace(BfAstNode* refNode, const StringImpl& nam
|
||||||
|
|
||||||
BfUsingFinder usingFinder;
|
BfUsingFinder usingFinder;
|
||||||
usingFinder.VisitMembers(refNode->GetSourceData()->mRootNode);
|
usingFinder.VisitMembers(refNode->GetSourceData()->mRootNode);
|
||||||
AddEntry(AutoCompleteEntry("fixit", StrFormat("using %s;\tusing|%s|%d||using %s;", namespaceStr.c_str(), parserData->mFileName.c_str(),
|
AddEntry(AutoCompleteEntry("fixit", StrFormat("using %s;\t.using|%s|%d||using %s;", namespaceStr.c_str(), parserData->mFileName.c_str(),
|
||||||
usingFinder.mLastIdx, namespaceStr.c_str()).c_str()));
|
usingFinder.mLastIdx, namespaceStr.c_str()).c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2888,7 +2888,7 @@ BfError* BfModule::Warn(int warningNum, const StringImpl& warning, BfAstNode* re
|
||||||
|
|
||||||
if (warningNum != 0)
|
if (warningNum != 0)
|
||||||
{
|
{
|
||||||
mCompiler->mResolvePassData->mAutoComplete->AddEntry(AutoCompleteEntry("fixit", StrFormat("#pragma warning disable %d\tusing|%s|%d||#pragma warning disable %d",
|
mCompiler->mResolvePassData->mAutoComplete->AddEntry(AutoCompleteEntry("fixit", StrFormat("#pragma warning disable %d\t.pragma|%s|%d||#pragma warning disable %d",
|
||||||
warningNum, parser->mFileName.c_str(), 0, warningNum).c_str()));
|
warningNum, parser->mFileName.c_str(), 0, warningNum).c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7356,7 +7356,7 @@ void BfModule::CheckTypeRefFixit(BfAstNode* typeRef, const char* appendName)
|
||||||
{
|
{
|
||||||
BfParserData* parser = typeRef->GetSourceData()->ToParserData();
|
BfParserData* parser = typeRef->GetSourceData()->ToParserData();
|
||||||
if (parser != NULL)
|
if (parser != NULL)
|
||||||
mCompiler->mResolvePassData->mAutoComplete->AddEntry(AutoCompleteEntry("fixit", StrFormat("using %s;\tusing|%s|%d||using %s;", namespaceStr.c_str(), parser->mFileName.c_str(), usingFinder.mLastIdx, namespaceStr.c_str()).c_str()));
|
mCompiler->mResolvePassData->mAutoComplete->AddEntry(AutoCompleteEntry("fixit", StrFormat("using %s;\t.using|%s|%d||using %s;", namespaceStr.c_str(), parser->mFileName.c_str(), usingFinder.mLastIdx, namespaceStr.c_str()).c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue