File tree Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Expand file tree Collapse file tree 2 files changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -216,10 +216,6 @@ export class InputComponent extends BaseComponent {
216216 2 ,
217217 ) ;
218218
219- // TODO:
220- // When 'cmdline' includes control characters that is displayed like '^Y', the display width
221- // is not equal to the length of the string. So we need to slice 'middle' to fit in the cmdwidth
222- // properly.
223219 const spacer = " " . repeat ( cmdwidth ) ;
224220 const middle = `${ this . #cmdline} ${ spacer } ` . slice (
225221 this . #offset,
Original file line number Diff line number Diff line change @@ -7,6 +7,9 @@ import { collect } from "jsr:@denops/std@^7.3.2/batch";
77
88import { dispatch } from "../event.ts" ;
99
10+ // deno-lint-ignore no-control-regex
11+ const CONTROL_CHARACTERS = / [ \x00 - \x1f \x7f ] / g;
12+
1013export class Cmdliner {
1114 #cmdline: string ;
1215 #cmdpos: number ;
@@ -72,6 +75,14 @@ export class Cmdliner {
7275 // Not in command-line mode
7376 return ;
7477 }
78+ // Check control characters in cmdline
79+ if ( CONTROL_CHARACTERS . test ( cmdline ) ) {
80+ // remove control characters
81+ await fn . setcmdline ( denops , cmdline . replace ( CONTROL_CHARACTERS , "" ) ) ;
82+ // retry check
83+ await this . check ( denops ) ;
84+ return ;
85+ }
7586 if ( cmdline !== this . #cmdline) {
7687 dispatch ( { type : "vim-cmdline-changed" , cmdline } ) ;
7788 }
You can’t perform that action at this time.
0 commit comments