Skip to content

Commit

Permalink
Merge replace target cases.
Browse files Browse the repository at this point in the history
  • Loading branch information
zufuliu committed Nov 14, 2023
1 parent b64e2a4 commit 383b9e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 14 deletions.
15 changes: 5 additions & 10 deletions scintilla/src/Editor.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -5749,9 +5749,10 @@ Sci::Position Editor::GetTag(char *tagValue, int tagNumber) {
return length;
}

Sci::Position Editor::ReplaceTarget(ReplaceType replaceType, std::string_view text) {
Sci::Position Editor::ReplaceTarget(Message iMessage, uptr_t wParam, sptr_t lParam) {
std::string_view text = ViewFromParams(lParam, wParam);
const UndoGroup ug(pdoc);
if (replaceType == ReplaceType::patterns) {
if (iMessage == Message::ReplaceTargetRE) {
Sci::Position length = text.length();
const char *p = pdoc->SubstituteByPosition(text.data(), &length);
if (!p) {
Expand All @@ -5760,7 +5761,7 @@ Sci::Position Editor::ReplaceTarget(ReplaceType replaceType, std::string_view te
text = std::string_view(p, length);
}

if (replaceType == ReplaceType::minimal) {
if (iMessage == Message::ReplaceTargetMinimal) {
// Check for prefix and suffix and reduce text and target to match.
// This is performed with Range which doesn't support virtual space.
Range range(targetRange.start.Position(), targetRange.end.Position());
Expand Down Expand Up @@ -6311,16 +6312,10 @@ sptr_t Editor::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) {
}

case Message::ReplaceTarget:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(ReplaceType::basic, ViewFromParams(lParam, wParam));

case Message::ReplaceTargetRE:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(ReplaceType::patterns, ViewFromParams(lParam, wParam));

case Message::ReplaceTargetMinimal:
PLATFORM_ASSERT(lParam);
return ReplaceTarget(ReplaceType::minimal, ViewFromParams(lParam, wParam));
return ReplaceTarget(iMessage, wParam, lParam);

case Message::SearchInTarget:
PLATFORM_ASSERT(lParam);
Expand Down
3 changes: 1 addition & 2 deletions scintilla/src/Editor.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,8 +605,7 @@ class Editor : public EditModel, public DocWatcher {
void FoldAll(Scintilla::FoldAction action);

Sci::Position GetTag(char *tagValue, int tagNumber);
enum class ReplaceType {basic, patterns, minimal};
Sci::Position ReplaceTarget(ReplaceType replaceType, std::string_view text);
Sci::Position ReplaceTarget(Scintilla::Message iMessage, Scintilla::uptr_t wParam, Scintilla::sptr_t lParam);

bool PositionIsHotspot(Sci::Position position) const noexcept;
bool SCICALL PointIsHotspot(Point pt);
Expand Down
2 changes: 1 addition & 1 deletion scintilla/src/RESearch.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ const char *RESearch::DoCompile(const char *pattern, size_t length, FindOption f
const bool posix = FlagSet(flags, FindOption::Posix);
char *mp = nfa; /* nfa pointer */
char *sp = nfa; /* another one */
const char *mpMax = mp + MAXNFA - BITBLK - 10;
const char * const mpMax = mp + MAXNFA - BITBLK - 10;

int tagstk[MAXTAG]{}; /* subpat tag stack */
int tagi = 0; /* tag stack index */
Expand Down
2 changes: 1 addition & 1 deletion scintilla/win32/ScintillaWin.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,7 @@ bool ScintillaWin::HandleLaTeXTabCompletion() {

targetRange.start.SetPosition(pos);
targetRange.end.SetPosition(main);
ReplaceTarget(ReplaceType::basic, std::string_view(buffer, len));
ReplaceTarget(Message::ReplaceTarget, len, reinterpret_cast<sptr_t>(buffer));
// move caret after character
SetEmptySelection(pos + len);
return true;
Expand Down

0 comments on commit 383b9e0

Please sign in to comment.