From db3e4e8cb1ead6e18d8a9c9328b29904c87257ec Mon Sep 17 00:00:00 2001 From: Sora Date: Fri, 24 Mar 2023 20:00:56 +0000 Subject: [PATCH] Fix tabs causing early cutoff Fix some more inalignments --- helix-term/src/ui/editor.rs | 10 +++++++--- runtime/queries/go/context.scm | 11 ++++++----- runtime/queries/zig/context.scm | 1 - 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/helix-term/src/ui/editor.rs b/helix-term/src/ui/editor.rs index dcce1d337..a3afa8d4a 100644 --- a/helix-term/src/ui/editor.rs +++ b/helix-term/src/ui/editor.rs @@ -793,10 +793,10 @@ impl EditorView { // define sticky context styles let context_style = theme .try_get("ui.sticky.context") - .unwrap_or_else(|| status_line_style); + .unwrap_or(status_line_style); let indicator_style = theme .try_get("ui.sticky.indicator") - .unwrap_or_else(|| status_line_style); + .unwrap_or(status_line_style); let mut context_area = viewport; context_area.height = 1; @@ -820,7 +820,11 @@ impl EditorView { } // get the len of bytes of the text that will be written (the "definition" line) - let already_written = text.line(node.line).len_bytes() as u16; + let line = text.line(node.line); + let tab_width_count = line.chars().filter(|c| *c == '\t').count(); + + let already_written = + (line.len_bytes() + tab_width_count.saturating_mul(doc.tab_width() - 1)) as u16; let dots = "..."; diff --git a/runtime/queries/go/context.scm b/runtime/queries/go/context.scm index e7ffd164e..d2c5f6ff9 100644 --- a/runtime/queries/go/context.scm +++ b/runtime/queries/go/context.scm @@ -1,17 +1,18 @@ ; Credits to nvim-treesitter/nvim-treesitter-context (function_declaration - result: (_) @context.end + body: (_) @context.end ) @context (method_declaration - result: (_) @context.end + body: (_) @context.end ) @context -[ +([ (const_declaration) - (if_statement) + (for_statement) + (if_statement) (import_declaration) (type_declaration) (var_declaration) -] @context +] @context) diff --git a/runtime/queries/zig/context.scm b/runtime/queries/zig/context.scm index 13b5df4b5..f5b6e8e94 100644 --- a/runtime/queries/zig/context.scm +++ b/runtime/queries/zig/context.scm @@ -1,5 +1,4 @@ (TopLevelDecl - (FnProto) (Block) @context.end ) @context