diff --git a/IDE/src/Commands.bf b/IDE/src/Commands.bf index 7fa1de36..f0b2de76 100644 --- a/IDE/src/Commands.bf +++ b/IDE/src/Commands.bf @@ -198,6 +198,7 @@ namespace IDE Add("Compile File", new => gApp.Cmd_CompileFile); Add("Debug All Tests", new () => { gApp.[Friend]RunTests(true, true); }); Add("Debug Normal Tests", new () => { gApp.[Friend]RunTests(false, true); }); + Add("Delete All Right", new => gApp.[Friend]DeleteAllRight); Add("Duplicate Line", new () => { gApp.[Friend]DuplicateLine(); }); Add("Exit", new => gApp.[Friend]Cmd_Exit); Add("Find All References", new => gApp.Cmd_FindAllReferences); diff --git a/IDE/src/IDEApp.bf b/IDE/src/IDEApp.bf index 62d80a50..29f0955e 100644 --- a/IDE/src/IDEApp.bf +++ b/IDE/src/IDEApp.bf @@ -2409,6 +2409,12 @@ namespace IDE //CloseWorkspace(); //FinishShowingNewWorkspace(); } + + [IDECommand] + void DeleteAllRight() + { + GetActiveSourceEditWidgetContent()?.DeleteAllRight(); + } [IDECommand] void DuplicateLine() diff --git a/IDE/src/ui/SourceEditWidgetContent.bf b/IDE/src/ui/SourceEditWidgetContent.bf index fa6014e8..dbb19ef7 100644 --- a/IDE/src/ui/SourceEditWidgetContent.bf +++ b/IDE/src/ui/SourceEditWidgetContent.bf @@ -2237,6 +2237,41 @@ namespace IDE.ui return false; } + + public void DeleteAllRight() + { + int startPos; + int endPos; + if (HasSelection()) + { + mSelection.ValueRef.GetAsForwardSelect(out startPos, out endPos); + } + else + { + startPos = endPos = CursorTextPos; + } + + int line; + int lineChar; + GetLineCharAtIdx(endPos, out line, out lineChar); + + let lineText = scope String(); + GetLineText(line, lineText); + + endPos += lineText.Length - lineChar; + + if (startPos == endPos) + { + return; + } + + mSelection = EditSelection(); + mSelection.ValueRef.mStartPos = (int32)startPos; + mSelection.ValueRef.mEndPos = (int32)endPos; + DeleteSelection(); + + CursorTextPos = startPos; + } public void DuplicateLine() {