sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
803 stars 39 forks source link

alt+q wrap_lines missing space before (, [ and { #6361

Open math2001 opened 4 months ago

math2001 commented 4 months ago

Description of the bug

alt+q wrap_lines removes spaces before (, { and [, but I don't think it should. Personally, I always want to keep the space.

Steps to reproduce

ctrl+n, open the console and paste

view.settings().set('wrap_width', 80)

Then paste in the buffer

Lorem ipsum dolor sit amet, consectetur adipisicing elit
(quis

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eisumod (commodo

And press alt+q for each paragraph.

Expected behavior

Lorem ipsum dolor sit amet, consectetur adipisicing elit (quis

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eisumod
(commodo

Actual behavior

Lorem ipsum dolor sit amet, consectetur adipisicing elit(quis

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eisumod(commodo

Sublime Text build number

4169

Operating system & version

Ubuntu 22.04

(Linux) Desktop environment and/or window manager

Gnome

Additional information

No response

OpenGL context information

No response

deathaxe commented 4 months ago

It probably shouldn't in text scope, but in source it might be possible the parentheses defining a function argument list, which most likely is not separated with space from function name.

void
func_name
(int arg1, int arg2)
{ return arg1 + arg2; }

is most likely expected to become

void func_name(int arg1, int arg2) { return arg1 + arg2; }

Space in front of { should however be preserved, ideally.

So whether whitespace should be removed or not may not be simple to answer.

math2001 commented 3 months ago

is alt+Q meant to be used on source code though?

deathaxe commented 3 months ago

Sure.

deathaxe commented 1 month ago

related report: https://forum.sublimetext.com/t/inhibit-removing-spaces-before-parentheses-when-wrapping-comments/73233

I have to set ruler to 78 instead of 80 with ST4180, but I can reproduce it. Space in front of column is removed, even though the whole line is not wrapped.

That kind of behavior is certainly a bug.

  1. Set syntax to C++
  2. Paste content from "before" block
  3. Set ruler to 78
  4. Hit alt+q

Before:

// The instruction buffer is a shift register with three 16-bit entries:
//
// * 2x 16-bit entries form the 32-bit current instruction register (CIR) which
//   is the processor's decode window
//

After

// The instruction buffer is a shift register with three 16-bit entries:
//
// * 2x 16-bit entries form the 32-bit current instruction register(CIR) which
//   is the processor's decode window
//