Giter VIP home page Giter VIP logo

Comments (7)

SamVerschueren avatar SamVerschueren commented on August 20, 2024 1

unless you listen for the onDidSaveTextDocument event

That's how it should be done. https://github.com/SamVerschueren/vscode-final-newline/blob/master/extension.ts#L65

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

This is expected behavior, see #40. This makes sure that the selection is set back to what it was before the save. This this works as well with multiple cursors and multiple selections. It does break intellisense however, but that can't be solved as long as it is not supported in VS Code core.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

@SamVerschueren, this issue is a different one. The selection is NOT set to what it was before, because it has the final newline selected (highlighted). See the following screen capture:

final-newline

If my cursor is anywhere else in the file when I trigger a save then it doesn't happen, but if my cursor is already on the very last character of the file, that's when it happens.

from editorconfig-vscode.

SamVerschueren avatar SamVerschueren commented on August 20, 2024

Oh you're right! Thanks for elaborating. Didn't add the put back part yet. This is odd. Should we implement to put back the selections after save then?

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

I tried to do that myself, but I wasn't having success and was running out of time so I reverted my changes. But yes, I do think we should restore the selections, if possible. The problem is that the TextEdit[] is not actually, itself, a Thenable<T>, so you can't really control the restoration of the selections unless you listen for the onDidSaveTextDocument event, so it gets pretty dirty. e.waitUntil(...) returns void, so you can't do a .then() on that either. It's frustrating.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

BTW, this also happens with multiple cursors, but only when one of those cursors is at the very end of the file.

from editorconfig-vscode.

jednano avatar jednano commented on August 20, 2024

Fixed and published in version 0.6.2!

from editorconfig-vscode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.