Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ This release fixes the following problems identified in fish 4.3.0:
- The sample prompts and themes are correctly installed (:issue:`12241`).
- Last line of command output could be hidden when missing newline (:issue:`12246`).

Interactive improvements
------------------------
- Existing file paths in redirection targets such as ``> file.txt`` are now highlighted using :envvar:`fish_color_valid_path`, indicating that ``file.txt`` will be clobbered (:issue:`12260`).

For distributors and developers
-------------------------------
- The CMake option ``WITH_GETTEXT`` has been renamed to ``WITH_MESSAGE_LOCALIZATION``, to reflect that it toggles localization independently of the backend used in the implementation.
Expand Down
10 changes: 9 additions & 1 deletion src/highlight/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,6 +969,11 @@ impl<'s> Highlighter<'s> {
HighlightRole::error
}),
);
if target_is_valid && self.io_still_ok() && self.file_tester.test_path(&target, false) {
for i in redir.target.source_range().as_usize() {
self.color_array[i].valid_path = true;
}
}
}

fn visit_variable_assignment(&mut self, varas: &VariableAssignment) {
Expand Down Expand Up @@ -1376,6 +1381,9 @@ mod tests {
let mut param_valid_path = HighlightSpec::with_fg(HighlightRole::param);
param_valid_path.valid_path = true;

let mut redirection_valid_path = HighlightSpec::with_fg(HighlightRole::redirection);
redirection_valid_path.valid_path = true;

let saved_flag = future_feature_flags::test(FeatureFlag::AmpersandNoBgInToken);
future_feature_flags::set(FeatureFlag::AmpersandNoBgInToken, true);
let _restore_saved_flag = ScopeGuard::new((), |_| {
Expand Down Expand Up @@ -1513,7 +1521,7 @@ mod tests {
("param1", fg(HighlightRole::param)),
// Input redirection.
("<", fg(HighlightRole::redirection)),
("/bin/echo", fg(HighlightRole::redirection)),
("/dev/null", redirection_valid_path),
// Output redirection to a valid fd.
("1>&2", fg(HighlightRole::redirection)),
// Output redirection to an invalid fd.
Expand Down
Loading