feat: Tab/автоотступ в редакторе + русский словарь ошибок (P1.4+P1.2) - #15
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96afe48d22
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!event.shiftKey && !selected.includes('\n')) { | ||
| editor.setRangeText(' ', start, end, 'end'); |
There was a problem hiding this comment.
Preserve one-line selections when Tab-indenting
When a user selects code within a single line and presses Tab, selected contains the whole line and therefore has no newline, so this branch replaces the actual selection with four spaces. For example, selecting print('hello') to indent it deletes the statement instead of indenting the selected line; distinguish a collapsed selection (start === end) from a nonempty one-line selection.
Useful? React with 👍 / 👎.
| const unindented = selected.replace(/^ {1,4}/gm, ''); | ||
| const removedBeforeCursor = Math.min(4, (value.slice(lineStart, start).match(/^ */) || [''])[0].length); | ||
| editor.value = value.slice(0, lineStart) + unindented + value.slice(lineEnd); | ||
| editor.setSelectionRange(start - removedBeforeCursor, end - (selected.length - unindented.length)); |
There was a problem hiding this comment.
Keep Shift+Tab selection endpoints aligned
When a multi-line selection ends inside the leading 1–3 spaces of its final line, this subtracts every space removed from that line even though some were after selectionEnd. For example, dedenting a selection from the first line's start through column 2 of the next four-space-indented line moves the endpoint two characters into the preceding line rather than to the next line's start, so subsequent typing operates on the wrong range.
Useful? React with 👍 / 👎.
| except (SyntaxError, ValueError) as error: | ||
| return {"correct": False, "message": str(error)} | ||
| error_text = f"{type(error).__name__}: {error}" | ||
| return {"correct": False, "message": str(error), "error": error_text} |
There was a problem hiding this comment.
Preserve sandbox-specific rejection guidance
When SafetyVisitor rejects an import, open, or another forbidden construct, it raises ValueError; exposing every caught ValueError through error now routes these policy rejections into translate_error's generic value-error category. Because the UI prioritizes error_hint over message, users are told to check a value's format instead of being clearly told that the operation is unsupported, so these safety errors need a distinct category or should retain their original guidance.
Useful? React with 👍 / 👎.
96afe48 to
a91df82
Compare
P1.4: Tab вставляет 4 пробела, Shift+Tab убирает отступ (в т.ч. по выделенным строкам), Enter наследует отступ и добавляет уровень после ':'. P1.2: app/error_hints.py переводит типовые ошибки Python (Syntax/Indent/Name/Type/Value/Index/Key/Attribute/ZeroDiv/Import/timeout) на дружелюбный русский с подсказкой; backend отдаёт error_hint, UI показывает его над сырой ошибкой. Тесты: 29 passed.