-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align view for background buffer opened with alt-ret
#7691
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
cb5c019
fix(picker): `alt-ret' changes cursor pos of current file, not new one
woojiq 1fdf84e
fix other pickers
woojiq 47e5e98
fix global and jumplist pickers
woojiq 2bced89
use `view` as old_id; make `align_view` method of `Action`
woojiq 01af29a
test(picker): basic <alt-ret> functionality
woojiq ba7f312
fix: picker integrational test
woojiq e853290
fix nit
woojiq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,6 +19,7 @@ mod test { | |
mod auto_pairs; | ||
mod commands; | ||
mod movement; | ||
mod picker; | ||
mod prompt; | ||
mod splits; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
use std::fs; | ||
|
||
use helix_core::{path::get_canonicalized_path, Range}; | ||
use helix_loader::{current_working_dir, set_current_working_dir}; | ||
use helix_view::{current_ref, editor::Action}; | ||
use tempfile::{Builder, TempDir}; | ||
|
||
use super::*; | ||
|
||
#[tokio::test(flavor = "multi_thread")] | ||
async fn test_picker_alt_ret() -> anyhow::Result<()> { | ||
// Create two files, open the first and run a global search for a word | ||
// from the second file. Press <alt-ret> to have helix open the second file in the | ||
// new buffer, but not change focus. Then check whether the word is highlighted | ||
// correctly and the view of the first file has not changed. | ||
let tmp_dir = TempDir::new()?; | ||
set_current_working_dir(tmp_dir.path().into())?; | ||
|
||
let mut app = AppBuilder::new().build()?; | ||
|
||
log::debug!( | ||
"set current working directory to {:?}", | ||
current_working_dir() | ||
); | ||
|
||
// Add prefix so helix doesn't hide these files in a picker | ||
let files = [ | ||
Builder::new().prefix("1").tempfile_in(&tmp_dir)?, | ||
Builder::new().prefix("2").tempfile_in(&tmp_dir)?, | ||
]; | ||
let paths = files | ||
.iter() | ||
.map(|f| get_canonicalized_path(f.path()).unwrap()) | ||
.collect::<Vec<_>>(); | ||
|
||
fs::write(&paths[0], "1\n2\n3\n4")?; | ||
fs::write(&paths[1], "first\nsecond")?; | ||
|
||
log::debug!( | ||
"created and wrote two temporary files: {:?} & {:?}", | ||
paths[0], | ||
paths[1] | ||
); | ||
|
||
// Manually open to save the offset, otherwise we won't be able to change the state in the Fn trait | ||
app.editor.open(files[0].path(), Action::Replace)?; | ||
let view_offset = current_ref!(app.editor).0.offset; | ||
|
||
test_key_sequences( | ||
&mut app, | ||
vec![ | ||
(Some("<space>/"), None), | ||
(Some("second<ret>"), None), | ||
( | ||
Some("<A-ret><esc>"), | ||
Some(&|app| { | ||
let (view, doc) = current_ref!(app.editor); | ||
assert_eq!(doc.path().unwrap(), &paths[0]); | ||
let select_ranges = doc.selection(view.id).ranges(); | ||
assert_eq!(select_ranges[0], Range::new(0, 1)); | ||
assert_eq!(view.offset, view_offset); | ||
}), | ||
), | ||
( | ||
Some(":buffer<minus>next<ret>"), | ||
Some(&|app| { | ||
let (view, doc) = current_ref!(app.editor); | ||
assert_eq!(doc.path().unwrap(), &paths[1]); | ||
let select_ranges = doc.selection(view.id).ranges(); | ||
assert_eq!(select_ranges.len(), 1); | ||
assert_eq!(select_ranges[0], Range::new(6, 12)); | ||
}), | ||
), | ||
], | ||
false, | ||
) | ||
.await?; | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is not quite the same thing. The diagnostic picker only seems to create a jumplist entry if not opening a new file. Admittetly this is a bit strange I would expect the various Lsp pickers to behavhe consistently. Do you know the history here @the-mikedavis?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's just an oversight: pushing a jump all of the time makes sense to me.