Prevent cell's edit mode from being incorrectly cleared when a text component is initialized. (#20120)

This commit is contained in:
Cory Rivera
2022-07-22 10:22:56 -07:00
committed by GitHub
parent 7176629e44
commit c2be6447b5
2 changed files with 31 additions and 25 deletions

View File

@@ -195,7 +195,6 @@ export class TextCellComponent extends CellView implements OnInit, OnChanges {
this._register(this.themeService.onDidColorThemeChange(this.updateTheme, this));
this.updateTheme(this.themeService.getColorTheme());
this.setFocusAndScroll();
this.cellModel.isEditMode = false;
this._htmlMarkdownConverter = this._instantiationService.createInstance(HTMLMarkdownConverter, this.notebookUri);
this._register(this.cellModel.onOutputsChanged(e => {
this.updatePreview();

View File

@@ -274,35 +274,42 @@ export function setup(opts: minimist.ParsedArgs) {
describe('Cell Toolbar Actions', function () {
async function verifyCellToolbarBehavior(app: Application, toolbarAction: () => Promise<void>, selector: string, checkIfGone: boolean = false): Promise<void> {
const sampleText: string = 'Test Text';
// Run the test for each of the default text editor modes
for (let editMode of ['Markdown', 'Split View']) {
await app.workbench.settingsEditor.addUserSetting('notebook.defaultTextEditMode', `"${editMode}"`);
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown');
let sampleText = `Markdown Toolbar Test - ${editMode}`;
await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText);
await app.workbench.sqlNotebook.selectAllTextInEditor();
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown');
await app.workbench.sqlNotebook.waitForPlaceholderGone();
await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Split View');
await app.workbench.sqlNotebook.waitForTypeInEditor(sampleText);
await app.workbench.sqlNotebook.selectAllTextInEditor();
await toolbarAction();
await app.code.dispatchKeybinding('escape');
if (checkIfGone) {
await app.workbench.sqlNotebook.waitForTextCellPreviewContentGone(selector);
} else {
await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, selector);
await toolbarAction();
await app.code.dispatchKeybinding('escape');
if (checkIfGone) {
await app.workbench.sqlNotebook.waitForTextCellPreviewContentGone(selector);
} else {
await app.workbench.sqlNotebook.waitForTextCellPreviewContent(sampleText, selector);
}
await app.workbench.quickaccess.runCommand('workbench.action.revertAndCloseActiveEditor');
}
}
async function verifyToolbarKeyboardShortcut(app: Application, keyboardShortcut: string, selector: string) {
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown');
await app.workbench.sqlNotebook.waitForPlaceholderGone();
await app.workbench.sqlNotebook.textCellToolbar.changeTextCellView('Markdown View');
let testText = 'Markdown Keyboard Shortcut Test';
await app.workbench.sqlNotebook.waitForTypeInEditor(testText);
await app.workbench.sqlNotebook.selectAllTextInEditor();
await app.code.dispatchKeybinding(keyboardShortcut);
await app.code.dispatchKeybinding('escape');
await app.workbench.sqlNotebook.waitForTextCellPreviewContent(testText, selector);
// Run the test for each of the default text editor modes
for (let editMode of ['Markdown', 'Split View']) {
await app.workbench.settingsEditor.addUserSetting('notebook.defaultTextEditMode', `"${editMode}"`);
await app.workbench.quickaccess.runCommand('workbench.action.closeActiveEditor');
await app.workbench.sqlNotebook.newUntitledNotebook();
await app.workbench.sqlNotebook.addCellFromPlaceholder('Markdown');
let testText = `Markdown Keyboard Shortcut Test - ${editMode}`;
await app.workbench.sqlNotebook.waitForTypeInEditor(testText);
await app.workbench.sqlNotebook.selectAllTextInEditor();
await app.code.dispatchKeybinding(keyboardShortcut);
await app.code.dispatchKeybinding('escape');
await app.workbench.sqlNotebook.waitForTextCellPreviewContent(testText, selector);
await app.workbench.quickaccess.runCommand('workbench.action.revertAndCloseActiveEditor');
}
}
it('can bold selected text', async function () {