Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Jump after the closing brackets (]]) on autocomplete #962

Closed
luisherranz opened this issue Mar 28, 2022 · 11 comments
Closed

Jump after the closing brackets (]]) on autocomplete #962

luisherranz opened this issue Mar 28, 2022 · 11 comments
Labels
enhancement New feature or request foam-vscode Foam for VSCode extension in packages/foam-vscode help wanted Extra attention is needed
Milestone

Comments

@luisherranz
Copy link

Is your feature request related to a problem? Please describe.

I'd love Foam to jump ahead the closing brackets ]] when I use autocomplete.

Describe the solution you'd like

When using autocomplete (by either clicking or using Tab/Enter on a result), Foam moves the cursor to the last word, like this:

  • I am linking to [[some page|]]

You then have to type ]] to continue writing.

It'd be great if Foam could jump ahead after the ]] instead, like this:

  • I am linking to [[some page]]|

Then you could open double brackets [[, partially complete the name of the page (some p), use Tab to finish the autocomplete, and keep writing the next words.

Describe alternatives you've considered

Write the ]] yourself, although I can't imagine a case where you wouldn't want to jump ahead. Similar software, like LogSeq, already works this way.

Screenshots or Videos

No response

@riccardoferretti
Copy link
Collaborator

That's an interesting optimization, I can see it speeding things up when writing notes.
I don't know whether it might interfere with some use cases (e.g. using sections), so this requires a bit of deep dive.
Happy to keep it in the backlog, and if someone wants to work on it I am happy to support, at least until v1 is out, at which point I could take a look myself.

@riccardoferretti riccardoferretti added enhancement New feature or request help wanted Extra attention is needed foam-vscode Foam for VSCode extension in packages/foam-vscode labels Mar 28, 2022
@riccardoferretti riccardoferretti added this to the backlog milestone Mar 28, 2022
@Lauviah0622
Copy link
Contributor

Lauviah0622 commented May 20, 2022

I'm trying to implement this feature but found problem. Like @riccardoferretti said, it will interfere the section use case.

Here is the demo, cursor jump after the closing bracket that cannot trigger the section auto completion.
movecursor

but the cursor move in section auto completion is work fine.

movecursor-sec

Maybe can trigger the cursor jump with tab button as jump to next placeholder in snippet? But I have no idea which api should I use can do that. if any idea, I can try to implement.

@luisherranz
Copy link
Author

Maybe leave it optional for people not using sections? (I'm not)

@riccardoferretti
Copy link
Collaborator

@Lauviah0622 Not sure which char you were using to confirm test in your first gif? what happens if you confirm the wikilink with the #? that must trigger the section autocomplete.
If instead you press enter and you get out of the wikilink, well, I think that could be fine.

@Lauviah0622
Copy link
Contributor

Lauviah0622 commented May 21, 2022

I'm sorry forgot to record my keystroke in demo! Here is the new version.
movecursor-withKey

And here is the file change on my current branch.

Because it just added the command after selection of auto complete simply, So It will move cursor with any confirm method - both press Enter and type # char.

I'll trying to use custom command to parse the regex of current line instead of the built in cursorMove command to prevent cursor moving after # .

@Lauviah0622
Copy link
Contributor

Lauviah0622 commented May 22, 2022

Here is the demo of completion. Not move cursor completion with #.
movecursoe-complete

And recording the suggest of the @luisherranz. I also add the setting of the feature that can turn the moving enabled/disabled. (I'm not native English speaker and need the help for the setting description)

movecursoe-setting

But there's a problem is, if user want use link alias, user should move cursor back to the start of the closing bracket by them self.

Maybe we can add another commitCharacters | of completion to fixed it.

@riccardoferretti
Copy link
Collaborator

@Lauviah0622 this looks pretty sweet. A few comments:

  • do we really need a setting? I think the behavior is good and intuitive enough that I would just have it on
  • I agree re the | commit character, good call

what do you think?

@Lauviah0622
Copy link
Contributor

Lauviah0622 commented May 23, 2022

@riccardoferretti Thank for appreciation.

do we really need a setting? I think the behavior is good and intuitive enough that I would just have it on

In my opinion, it's the subtle change and like you said its the enhancement with no effort. If there is any reason that need a setting to disabled, which is the feature maybe will confuse somebody's muscle memory. But I think it's just a matter of getting used to it.

I agree re the | commit character, good call

I'm agree with that ! Its make the operation so smooth. Here is demo:

movecursoe-cmt-cha

@riccardoferretti
Copy link
Collaborator

I absolutely love it!

@luisherranz
Copy link
Author

Awesome!

Will this work with Tab as well if that is what people use in VS Code, or is it hardcoded to Enter?

@luisherranz
Copy link
Author

Will this work with Tab as well if that is what people use in VS Code, or is it hardcoded to Enter?

It does 🙂

I've been using it for a few days now and I absolutely love it. Thanks a lot @Lauviah0622 🎉

Closing this as complete now.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request foam-vscode Foam for VSCode extension in packages/foam-vscode help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants