sublime-fmt icon indicating copy to clipboard operation
sublime-fmt copied to clipboard

Provide variable for current selection

Open rchl opened this issue 3 years ago • 6 comments

I was checking your code to see if I could use it to replace my clang-format plugin [1] and found that my plugin also supports formatting just the selection. Or at least passing the current selection to clang-format [2].

Maybe you could provide variables that would expand to selection_start, selection_end offsets, and also selection_length?

(Although, I've just realized while writing this, that we wouldn't want to pass -offset and -length when the selection is empty so that could be another thing that would make supporting this tricky...)

[1] https://github.com/rchl/SublimeClangFormat [2] https://github.com/rchl/SublimeClangFormat/blob/9d4f804e82b471928fab0c347ccabefccaf9240c/ClangFormat.py#L128-L132

(Also, I would really want to run formatting on a separate thread so that the UI doesn't block when formatting MB-big files).

rchl avatar Dec 19 '20 21:12 rchl