zufuliu / notepad4

Notepad4 (Notepad2⨯2, Notepad2++) is a light-weight Scintilla based text editor for Windows with syntax highlighting, code folding, auto-completion and API list for many programming languages and documents, bundled with file browser plugin matepath.
Other
2.56k stars 179 forks source link

改进注释相关功能 #718

Closed Crystal-RainSlide closed 9 months ago

Crystal-RainSlide commented 11 months ago
  1. 支持切换块注释:

    目前块注释只能添加,不能切换/去除,会影响下面功能的实现。

  2. 改进 CSS 的注释:

    虽然 Less 等二次语言支持使用 // 来进行单行注释,但 CSS 本身只支持形如 /* */ 的注释。所以,使用 Ctrl + / 在 CSS 文件中切换单行注释时,最好也能加上块注释 /* */,而不是只能用 Ctrl + Q 添加块注释。在实现上面一点之前,可以考虑先和 HTML 一样,(为 CSS)禁用行注释,只允许块注释;

    P.S. 对于不支持行注释(例如 CSS)或不支持块注释(例如批处理)的情况,可以考虑在用户按下有关快捷键时显示一个提示。用检测到二进制文件进入只读模式的那个小提示框应该就够了。

  3. 注释内外空格:

    建议新增设置项,允许设置是否应当加空格,来保证注释符前后为空白字符(空格或换行符)。这样更接近许多其他代码编辑器的行为。

zufuliu commented 11 months ago

建议新增设置项,允许设置要不要通过加空格的方式

Space is added after #711.

zufuliu commented 11 months ago

可以考虑先和 HTML 一样,(为 CSS)禁用行注释,只允许块注释;

Ctrl + / for standard CSS is disabled by 90dfbf8f6370b2410a692cdab092ff190e234e48.

zufuliu commented 11 months ago

建议新增设置项,允许设置要不要通过加空格的方式,来保证注释符前后为空白字符

baf1cc1bfc95fa633bcfca5fbae88d3d794df4a6 added option "Insert space after comment marker on toggle line comment." on Auto Completion Settings dialog. Auto Completion Settings

zufuliu commented 11 months ago

支持切换块注释

Toggle block comment is implemented by 3e79284d0cae3edc3ef782bf40b07d6171919865.

image

zufuliu commented 11 months ago

使用 Ctrl + / 在 CSS 文件中切换单行注释时,最好也能加上块注释 /* */,而不是只能用 Ctrl + Q 添加块注释

Implemented by 3494f2e39a208276e7b84e78cb0ccb5dcb22fb7c. since this commit, Ctrl + / and Ctrl + Q are interchangeable for scheme with only line comment or block comment, however currently only enabled for CSS, HTML, PHP and XML (where both menus are enabled), this matches Visual Studio Code. uncomment following lines would matches Sublime Text:

https://github.com/zufuliu/notepad2/blob/3494f2e39a208276e7b84e78cb0ccb5dcb22fb7c/src/Notepad2.c#L2562-L2563

zufuliu commented 10 months ago

EditUncommentBlock() can be simplified when boost regex (#725) is used, .e.g. /\*.+?\*/ (non-greedy, with dot match all character include newline) would find current C++ comment block.