@@ -1023,6 +1023,7 @@ fn goto_file_vsplit(cx: &mut Context) {
1023 goto_file_impl(cx, Action::VerticalSplit);
1023 goto_file_impl(cx, Action::VerticalSplit);
1026+/// Goto files in selection.
1026fn goto_file_impl(cx: &mut Context, action: Action) {
1027fn goto_file_impl(cx: &mut Context, action: Action) {
1027 let (view, doc) = current_ref!(cx.editor);
1028 let (view, doc) = current_ref!(cx.editor);
1028 let text = doc.text();
1029 let text = doc.text();
@@ -1032,15 +1033,25 @@ fn goto_file_impl(cx: &mut Context, action: Action) {
1032 .map(|r| text.slice(r.from()..r.to()).to_string())
1033 .map(|r| text.slice(r.from()..r.to()).to_string())
1033 .collect();
1034 .collect();
1034 let primary = selections.primary();
1035 let primary = selections.primary();
1036+ // Checks whether there is only one selection with a width of 1
1035− if selections.len() == 1 && primary.to() - primary.from() == 1 {
1037+ if selections.len() == 1 && primary.len() == 1 {
1036− let current_word = movement::move_next_long_word_start(
1038+ let count = cx.count();
1037− text.slice(..),
1039+ let text_slice = text.slice(..);
1038− movement::move_prev_long_word_start(text.slice(..), primary, 1),
1040+ // In this case it selects the WORD under the cursor
1039− 1,
1041+ let current_word = textobject::textobject_word(
1044+ textobject::TextObject::Inside,
1048+ // Trims some surrounding chars so that the actual file is opened.
1049+ let surrounding_chars: &[_] = &['\'', '"', '(', ')'];
1041 paths.clear();
1050 paths.clear();
1042 paths.push(
1051 paths.push(
1043− text.slice(current_word.from()..current_word.to())
1052+ current_word
1053+ .fragment(text_slice)
1054+ .trim_matches(surrounding_chars)
1044 .to_string(),
1055 .to_string(),