feat: enable reset in multifile editor (#43617)

* feat: dispatch resetChallenge action

* fix: copy challengeFiles instead of in-place sort

* fix: handle null updateFile payloads in redux

* refactor: reorganise region initialization

* refactor: pull code into editorDidMount

Then we can rely on the presence of the editor and monaco and don't have
litter the code with null checks.

* refactor: use better name for editable region init

* refactor: remove unused decoration

* refactor: rename forbidden region init functions

* fix: keep all challengeFiles when resetting

* refactor: remove unused decoration class

* fix: reinitialize editor on reset

* fix: stop adding multiple scroll listeners

Since the challengeFile update on each keystroke extra (unnecessary)
adding of listeners slowed the editor to a crawl.

* fix: only scroll to editor on mount

Rather than on any edit.

* refactor: remove logs and comments

* fix: rename toSortedArray and fix broken test

* fix: check for null not falsy in updateFile

* fix: only update project features when project

* fix: only reset if editor contents have changed

* feat: focus on editor after reset
This commit is contained in:
Oliver Eyton-Williams
2021-10-01 10:36:20 +02:00
committed by GitHub
parent eb6d3e214f
commit e4ba0e23ea
9 changed files with 218 additions and 175 deletions

View File

@ -43,7 +43,7 @@ const testEvaluator =
const { getLines } = require('../../utils/get-lines');
const { isAuditedCert } = require('../../utils/is-audited');
const { toSortedArray } = require('../../utils/sort-files');
const { sortChallengeFiles } = require('../../utils/sort-challengefiles');
const {
getChallengesForLang,
getMetaForBlock,
@ -471,7 +471,7 @@ ${inspect(commentMap)}
// TODO: the no-solution filtering is a little convoluted:
const noSolution = new RegExp('// solution required');
const solutionsAsArrays = solutions.map(toSortedArray);
const solutionsAsArrays = solutions.map(sortChallengeFiles);
const filteredSolutions = solutionsAsArrays.filter(solution => {
return !isEmpty(