Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move viewModel utilities into testNotebookEditor.ts #211995

Open
Yoyokrazy opened this issue May 3, 2024 · 1 comment
Open

Move viewModel utilities into testNotebookEditor.ts #211995

Yoyokrazy opened this issue May 3, 2024 · 1 comment
Assignees
Labels
debt Code quality issues notebook-toc-outline

Comments

@Yoyokrazy
Copy link
Contributor

Yoyokrazy commented May 3, 2024

we could consider moving these utilities into testNotebookEditor

Originally posted by @rebornix in #211861 (comment)

function createCodeCellViewModel(version: number = 1, source = '# code', textmodelId = 'textId') {
return {
textBuffer: {
getLineCount() { return 0; }
},
getText() {
return source;
},
model: {
textModel: {
id: textmodelId,
getVersionId() { return version; }
}
},
resolveTextModel() {
return this.model.textModel as unknown;
},
cellKind: 2
} as ICellViewModel;
}
function createMarkupCellViewModel(version: number = 1, source = 'markup', textmodelId = 'textId', alternativeId = 1) {
return {
textBuffer: {
getLineCount() { return 0; }
},
getText() {
return source;
},
getAlternativeId() {
return alternativeId;
},
model: {
textModel: {
id: textmodelId,
getVersionId() { return version; }
}
},
resolveTextModel() {
return this.model.textModel as unknown;
},
cellKind: 1
} as ICellViewModel;
}

@Yoyokrazy Yoyokrazy self-assigned this May 3, 2024
@Yoyokrazy
Copy link
Contributor Author

Yoyokrazy commented May 3, 2024

additionally, change source parameter to take in string[]. leaves us with an accurate way to call getLineCount

function createCodeCellViewModel(version: number = 1, source = '# code', textmodelId = 'textId') {
return {
textBuffer: {
getLineCount() { return 0; }

@Yoyokrazy Yoyokrazy added debt Code quality issues notebook-toc-outline labels May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
debt Code quality issues notebook-toc-outline
Projects
None yet
Development

No branches or pull requests

1 participant