diff --git a/.vscode/settings.json b/.vscode/settings.json index cf1f836b8..5c8bfa763 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,8 @@ { "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, "files.watcherExclude": { "**/.git/objects/**": true, "**/.git/subtree-cache/**": true, diff --git a/docs/development.md b/docs/development.md index 96eec4b94..f5e7a2394 100644 --- a/docs/development.md +++ b/docs/development.md @@ -141,6 +141,13 @@ that's causing the problem, and then run bazel run //ts:format ``` +If you get complaints from eslint about unordered imports, run the following +line first, then run ts:format: + +``` +bazel run eslint -- --fix +``` + For other packages, change to the folder and run ``` diff --git a/pylib/anki/template.py b/pylib/anki/template.py index ed63516b4..3c0267949 100644 --- a/pylib/anki/template.py +++ b/pylib/anki/template.py @@ -158,6 +158,7 @@ class TemplateRenderContext: self._fill_empty = fill_empty self._fields: dict | None = None self._latex_svg = False + self._question_side: bool = True if not notetype: self._note_type = note.note_type() else: @@ -167,6 +168,10 @@ class TemplateRenderContext: # hooks, you can insert it into this dictionary self.extra_state: dict[str, Any] = {} + @property + def question_side(self) -> bool: + return self._question_side + def col(self) -> anki.collection.Collection: return self._col @@ -226,9 +231,11 @@ class TemplateRenderContext: answer_av_tags=[], ) + self._question_side = True qtext = apply_custom_filters(partial.qnodes, self, front_side=None) qout = self.col()._backend.extract_av_tags(text=qtext, question_side=True) + self._question_side = False atext = apply_custom_filters(partial.anodes, self, front_side=qout.text) aout = self.col()._backend.extract_av_tags(text=atext, question_side=False) diff --git a/pylib/tests/run_format.py b/pylib/tests/run_format.py index ceaa67bc5..f6a676d68 100644 --- a/pylib/tests/run_format.py +++ b/pylib/tests/run_format.py @@ -39,7 +39,7 @@ if __name__ == "__main__": "anki", "tests", "tools", - "--exclude=_pb2|buildinfo|_gen", + "--exclude=_pb2|buildinfo|_gen|_backend/generated|fluent", ] + args, check=False, diff --git a/repos.bzl b/repos.bzl index c06153208..922078db5 100644 --- a/repos.bzl +++ b/repos.bzl @@ -115,12 +115,12 @@ def register_repos(): ################ core_i18n_repo = "anki-core-i18n" - core_i18n_commit = "0d97543af78a11c7cc4f2af34f4eaef18e86cae9" - core_i18n_zip_csum = "ca722979b1c6ff4098d5fc3b91a723e51ac760e1a723ac46983c05248e4e79e2" + core_i18n_commit = "f404191d521051946b824d7974b14aff35932016" + core_i18n_zip_csum = "da823e153ff55ca1bb46d8e1eb5b74ca723f596abf85fb530f2457d17d0ffa05" qtftl_i18n_repo = "anki-desktop-ftl" - qtftl_i18n_commit = "9eda7432ff61768e867376bf7e4cf9a450056c9b" - qtftl_i18n_zip_csum = "6544d7d02cf605559f8d1ac1103d9375b2a2ecad499734dff748cf2675d59deb" + qtftl_i18n_commit = "51724fbb327815358d6f896a4f79cf9cb2303562" + qtftl_i18n_zip_csum = "e8f4723eb6d20432754b08c19164fbaafd43ff8222779e2a7cd1fb835f41c7b5" i18n_build_content = """ filegroup( diff --git a/rslib/src/decks/limits.rs b/rslib/src/decks/limits.rs index d62ad9519..5120e0d1b 100644 --- a/rslib/src/decks/limits.rs +++ b/rslib/src/decks/limits.rs @@ -122,7 +122,9 @@ impl LimitTreeMap { .unwrap(); let mut map = HashMap::new(); - map.insert(root_deck.id, root_id.clone()); + if root_limits.limits.review > 0 { + map.insert(root_deck.id, root_id.clone()); + } let mut limits = Self { tree, map }; let mut remaining_decks = child_decks.into_iter().peekable(); diff --git a/rslib/src/scheduler/queue/builder/mod.rs b/rslib/src/scheduler/queue/builder/mod.rs index 8da5b11a9..dd0045ba4 100644 --- a/rslib/src/scheduler/queue/builder/mod.rs +++ b/rslib/src/scheduler/queue/builder/mod.rs @@ -287,6 +287,13 @@ mod test { self.add_or_update_deck(deck).unwrap(); } + fn set_deck_review_limit(&mut self, deck: DeckId, limit: u32) { + let dcid = self.get_deck(deck).unwrap().unwrap().config_id().unwrap(); + let mut conf = self.get_deck_config(dcid, false).unwrap().unwrap(); + conf.inner.reviews_per_day = limit; + self.add_or_update_deck_config(&mut conf).unwrap(); + } + fn queue_as_deck_and_template(&mut self, deck_id: DeckId) -> Vec<(DeckId, u16)> { self.build_queues(deck_id) .unwrap() @@ -318,6 +325,18 @@ mod test { } } + #[test] + fn should_build_empty_queue_if_limit_is_reached() { + let mut col = open_test_collection(); + col.set_config_bool(BoolKey::Sched2021, true, false) + .unwrap(); + let note_id = col.add_new_note("Basic").id; + let cids = col.storage.card_ids_of_notes(&[note_id]).unwrap(); + col.set_due_date(&cids, "0", None).unwrap(); + col.set_deck_review_limit(DeckId(1), 0); + assert_eq!(col.queue_as_deck_and_template(DeckId(1)), vec![]); + } + #[test] fn new_queue_building() -> Result<()> { let mut col = open_test_collection(); diff --git a/ts/components/WithTooltip.svelte b/ts/components/WithTooltip.svelte index 8bafa1b76..6adbb7c11 100644 --- a/ts/components/WithTooltip.svelte +++ b/ts/components/WithTooltip.svelte @@ -43,9 +43,11 @@ let previousTooltip: string = tooltip; $: if (tooltip !== previousTooltip) { previousTooltip = tooltip; - const element: HTMLElement = tooltipObject["_element"]; - tooltipObject.dispose(); - createTooltip(element); + if (tooltipObject !== undefined) { + const element: HTMLElement = tooltipObject["_element"]; + tooltipObject.dispose(); + createTooltip(element); + } } diff --git a/ts/deck-options/SaveButton.svelte b/ts/deck-options/SaveButton.svelte index 6aa2ecea7..71cbb1da9 100644 --- a/ts/deck-options/SaveButton.svelte +++ b/ts/deck-options/SaveButton.svelte @@ -66,7 +66,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html tooltip={getPlatformString(saveKeyCombination)} --border-left-radius="5px">{tr.deckConfigSaveButton()} - save(false)} /> + save(false)} /> /g, ">").replace(/&/g, "&"); + return value.replace(/&/g, "&").replace(//g, ">"); } export function unescapeSomeEntities(value: string): string { diff --git a/ts/editor/NoteEditor.svelte b/ts/editor/NoteEditor.svelte index 9f5cce9c2..754628b29 100644 --- a/ts/editor/NoteEditor.svelte +++ b/ts/editor/NoteEditor.svelte @@ -40,7 +40,6 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html import Absolute from "../components/Absolute.svelte"; import Badge from "../components/Badge.svelte"; import { bridgeCommand } from "../lib/bridgecommand"; - import { isApplePlatform } from "../lib/platform"; import { ChangeTimer } from "./change-timer"; import DecoratedElements from "./DecoratedElements.svelte"; import { clearableArray } from "./destroyable"; @@ -70,7 +69,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html return fontFamily; } - const size = isApplePlatform() ? 1.6 : 1.8; + const size = 1.6; const wrap = true; const fieldStores: Writable[] = []; diff --git a/ts/editor/image-overlay/ImageHandle.svelte b/ts/editor/image-overlay/ImageHandle.svelte index 3021e222e..f1f9e819a 100644 --- a/ts/editor/image-overlay/ImageHandle.svelte +++ b/ts/editor/image-overlay/ImageHandle.svelte @@ -152,12 +152,13 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html } /** - * Image resizing add-ons previously used image.style.width to set the - * preferred width of an image. In these cases, if we'd only set - * image.width, there would be no visible effect on the image. - * To avoid confusion with users we'll clear image.style.width (for now). + * Image resizing add-ons previously used image.style.width/height to set the + * preferred dimension of an image. In these cases, if we'd only set + * image.[dimension], there would be no visible effect on the image. + * To avoid confusion with users we'll clear image.style.[dimension] (for now). */ activeImage!.style.removeProperty("width"); + activeImage!.style.removeProperty("height"); if (activeImage!.getAttribute("style")?.length === 0) { activeImage!.removeAttribute("style"); } diff --git a/ts/editor/tag-editor/TagEditor.svelte b/ts/editor/tag-editor/TagEditor.svelte index 527688f3d..2fabe8bb1 100644 --- a/ts/editor/tag-editor/TagEditor.svelte +++ b/ts/editor/tag-editor/TagEditor.svelte @@ -112,6 +112,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html function appendEmptyTag(): void { // used by tag badge and tag spacer + deselect(); const lastTag = tagTypes[tagTypes.length - 1]; if (!lastTag || lastTag.name.length > 0) { @@ -219,6 +220,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html activeAfterBlur = index - 1; active = null; + activeInput.blur(); } async function moveToNextTag(index: number): Promise { @@ -232,6 +234,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html activeAfterBlur = index + 1; active = null; + activeInput.blur(); await tick(); activeInput.setSelectionRange(0, 0); @@ -448,6 +451,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html splitTag(index, detail.start, detail.end)} on:tagadd={() => insertTagKeepFocus(index)} on:tagdelete={() => deleteTagAt(index)} + on:tagselectall={selectAllTags} on:tagjoinprevious={() => joinWithPreviousTag(index)} on:tagjoinnext={() => joinWithNextTag(index)} on:tagmoveprevious={() => moveToPreviousTag(index)} diff --git a/ts/editor/tag-editor/TagInput.svelte b/ts/editor/tag-editor/TagInput.svelte index a9f0f40d4..b9f7c1f32 100644 --- a/ts/editor/tag-editor/TagInput.svelte +++ b/ts/editor/tag-editor/TagInput.svelte @@ -5,6 +5,7 @@ License: GNU AGPL, version 3 or later; http://www.gnu.org/licenses/agpl.html