Skip to content

Commit

Permalink
Fix undo
Browse files Browse the repository at this point in the history
  • Loading branch information
fcollonval committed Oct 14, 2023
1 parent 116ef6b commit b4b6201
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import {
regexIcon
} from '@jupyterlab/ui-components';
import type { CommandRegistry } from '@lumino/commands';
import { PromiseDelegate } from '@lumino/coreutils';
import { Message } from '@lumino/messaging';
import React, { useEffect, useState } from 'react';
import { AskBoolean } from './askBoolean';
Expand Down Expand Up @@ -491,9 +492,17 @@ export class SearchReplaceView extends VDomRenderer<SearchReplaceModel> {
matches: SearchReplace.IReplacement[]
): Promise<IDocumentWidget<FileEditor>> {
const widget = await this.openFile(path);
await widget.context.ready;
await Promise.all([widget.context.ready, widget.content.ready]);

const editor = widget.content.editor as CodeMirrorEditor;

// Add arbitrary delay for the shared model to set up properly its undo manager
const waitForTimeout = new PromiseDelegate<void>();
window.setTimeout(() => {
waitForTimeout.resolve();
}, 300);
await waitForTimeout.promise;

// Sort from end to start to preserve match positions
matches
.sort((a, b) => {
Expand Down
6 changes: 2 additions & 4 deletions ui-tests/tests/replacePerItem.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@ test('should replace results for a particular file only', async ({ page }) => {
);
});

// FIXME
test.skip('should undo replace results for a particular file only', async ({
test('should undo replace results for a particular file only', async ({
page
}) => {
await page.getByRole('tab', { name: 'Search and Replace' }).click();
Expand Down Expand Up @@ -229,8 +228,7 @@ test('should replace results for a particular match only', async ({ page }) => {
);
});

// FIXME
test.skip('should undo replace results for a particular match only', async ({
test('should undo replace results for a particular match only', async ({
page
}) => {
await page.getByRole('tab', { name: 'Search and Replace' }).click();
Expand Down
2 changes: 1 addition & 1 deletion ui-tests/tests/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ test('should replace results on replace-all button', async ({ page }) => {

await page
.getByRole('textbox', { name: 'Search Files for Text' })
.fill('hello');
.fill('hola');
await Promise.all([
page.waitForResponse(
response =>
Expand Down

0 comments on commit b4b6201

Please sign in to comment.