pub struct EditorCommand { /* private fields */ }Expand description
A parsed [review].editor — the command that opens a file at a line.
A command, not a name, and the only key in this module that is. agent
and theme are names because the invocation behind each carries more than
an argv: an agent is handed a tool allowlist and a prompt written for what
it can do (ADR 0022, 0033), and a palette is thirty-odd values derived
together so the chrome and the code cannot disagree (ADR 0024). In both, a
free-form value would have been a knob that looked like it worked.
Neither reason reaches an editor. The invocation carries a path and a line and nothing else, every editor spells the line differently, and a name would have frozen the list of editors a reader may use into an enum in this crate. So the reader writes the command (ADR 0038).
Parsed once, at load, so a command that cannot be split is an error the reader sees when they start rather than when they press the key.
Implementations§
Source§impl EditorCommand
impl EditorCommand
Sourcepub fn parse(text: &str, origin: &str) -> Result<EditorCommand, EngineError>
pub fn parse(text: &str, origin: &str) -> Result<EditorCommand, EngineError>
Split the command into words. origin names the file or the variable
it came from, for the error.
shlex does the splitting rather than a hand-rolled scanner (design
rule 5): quoting is the whole of the problem here, and a path with a
space in it is the case that would have found a hand-rolled bug.
Sourcepub fn argv(&self, file: &Path, line: u32) -> Vec<String>
pub fn argv(&self, file: &Path, line: u32) -> Vec<String>
The argv that opens file at line.
A command naming no {file} gets the path appended, which is what
makes a bare $EDITOR work; it opens the file at the top, and
carries_line is what lets the caller say so.
{line} is substituted before {file}. A path holding the literal
text {line} would otherwise be read as a placeholder by the second
pass. str::replace never re-scans what it inserts, so one order is
all it takes.
The path is rendered lossily, as every path in the renderer above this
already is — schema::FileEntry::path is a String.
Substitution reaches every word but the first, which parse
has already refused to let hold a placeholder.
Sourcepub fn carries_line(&self) -> bool
pub fn carries_line(&self) -> bool
Whether the command says where the line goes. false means the editor
opens the file at the top, which the reader is owed a word about.
Trait Implementations§
Source§impl Clone for EditorCommand
impl Clone for EditorCommand
Source§impl Debug for EditorCommand
impl Debug for EditorCommand
impl Eq for EditorCommand
Source§impl PartialEq for EditorCommand
impl PartialEq for EditorCommand
impl StructuralPartialEq for EditorCommand
Auto Trait Implementations§
impl Freeze for EditorCommand
impl RefUnwindSafe for EditorCommand
impl Send for EditorCommand
impl Sync for EditorCommand
impl Unpin for EditorCommand
impl UnsafeUnpin for EditorCommand
impl UnwindSafe for EditorCommand
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.