Skip to content

Commit

Permalink
Fix isearch-exit to keep the mark mode behavior (#1745)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitphx authored Nov 6, 2023
1 parent dce0580 commit e412b0c
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/commands/find.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,23 @@ export class IsearchExit extends IsearchCommand {
public readonly id = "isearchExit";

public run(textEditor: TextEditor, isInMarkMode: boolean, prefixArgument: number | undefined): Thenable<void> {
if (this.searchState.startSelections) {
this.emacsController.pushMark(this.searchState.startSelections.map((selection) => selection.anchor));
MessageManager.showMessage("Mark saved where search started");
}
return vscode.commands
.executeCommand("closeFindWidget")
.then(() => vscode.commands.executeCommand("cancelSelection"));
return vscode.commands.executeCommand("closeFindWidget").then(() => {
const startSelections = this.searchState.startSelections;
if (startSelections) {
if (isInMarkMode) {
// Restore the mark mode selections
textEditor.selections = textEditor.selections.map((selection, index) => {
const startSelection = startSelections[index];
if (startSelection == null) {
return selection;
}
return new vscode.Selection(startSelection.anchor, selection.active);
});
} else {
this.emacsController.pushMark(startSelections.map((selection) => selection.anchor));
MessageManager.showMessage("Mark saved where search started");
}
}
});
}
}

0 comments on commit e412b0c

Please sign in to comment.