feat: add theme management with light and dark modes
- Implemented a new composable `useTheme` for managing theme state. - Added functions to read and write theme preference to local storage. - Applied theme styles to the DOM based on user preference. - Introduced a toggle function to switch between light and dark themes. refactor: enhance copilot plugin functionality - Improved request handling with sequence and document versioning. - Refactored ghost text handling to improve clarity and efficiency. - Updated markdown insertion logic to handle parsed content more robustly. - Enhanced error handling and logging for better debugging. style: update global styles for light and dark themes - Defined CSS variables for light and dark themes to streamline styling. - Improved overall styling consistency and responsiveness. - Added transitions for smoother theme changes and interactions.
This commit is contained in:
@@ -1,9 +1,5 @@
|
||||
from typing import Tuple
|
||||
|
||||
MAX_PREFIX_CHARS = 12000
|
||||
MAX_SUFFIX_CHARS = 4000
|
||||
|
||||
|
||||
def _sanitize_language_id(language_id: str) -> str:
|
||||
if not language_id:
|
||||
return "markdown"
|
||||
@@ -18,12 +14,12 @@ def _sanitize_language_id(language_id: str) -> str:
|
||||
def _prepare_context(prefix: str, suffix: str) -> Tuple[str, str]:
|
||||
"""
|
||||
Prepare prefix/suffix for model completion context.
|
||||
Keep the historical one-char lookahead behavior to reduce boundary drift.
|
||||
"""
|
||||
if suffix:
|
||||
prefix = prefix + suffix[0]
|
||||
suffix = suffix[1:]
|
||||
return prefix[-MAX_PREFIX_CHARS:], suffix[:MAX_SUFFIX_CHARS]
|
||||
return prefix, suffix
|
||||
|
||||
|
||||
def prepare_prompt_context(prefix: str, suffix: str) -> Tuple[str, str]:
|
||||
return _prepare_context(prefix, suffix)
|
||||
|
||||
|
||||
def build_prompt(prefix: str, suffix: str, language_id: str = "markdown") -> str:
|
||||
@@ -50,8 +46,8 @@ Hard rules:
|
||||
Do NOT repeat text that already appears at the start of SUFFIX.
|
||||
3. Balanced length:
|
||||
Prefer concise but meaningful continuation, not ultra-short fragments.
|
||||
Default target is 20-120 characters and 1-3 lines.
|
||||
You may go shorter only when syntax requires it.
|
||||
Default target is 20-120 characters and 1-3 lines for plain prose.
|
||||
You may be longer when structure requires it (lists, tables, code blocks, math blocks).
|
||||
4. Avoid trivial output:
|
||||
Do not output only punctuation or filler such as ".", ",", ";", ":".
|
||||
Do not output just one token unless it is structurally necessary.
|
||||
@@ -60,10 +56,12 @@ Hard rules:
|
||||
6. Markdown awareness:
|
||||
Continue active list/checkbox/ordered-list patterns when applicable.
|
||||
Preserve indentation in nested list/code contexts.
|
||||
You may output full markdown structures when context needs them: headings, lists, tables, fenced code blocks, blockquotes, and LaTeX ($...$ / $$...$$).
|
||||
Close obvious unclosed inline markdown markers only when needed to bridge.
|
||||
7. Strict output format:
|
||||
Output insertion text only.
|
||||
No explanations, labels, quotes, or code fences.
|
||||
No explanations, labels, or wrapper quotes around the whole output.
|
||||
Markdown syntax is allowed when it is the intended insertion (including fenced code blocks and LaTeX).
|
||||
|
||||
Decision policy:
|
||||
- If PREFIX already connects naturally to SUFFIX, add a brief but useful continuation when possible.
|
||||
@@ -91,3 +89,6 @@ Now produce the insertion.
|
||||
Output:"""
|
||||
|
||||
return prompt.strip()
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user