git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] userdiff: add builtin diff driver for TypeScript language

From
Matthew Hughes <matthewhughes934@gmail.com>
Date
Jul 16, 2024, 12:21 UTC
Message-ID
<20240716122112.zqauqgxmng2tk2j6@archP14s>
In-Reply-To
<pull.1746.git.git.1721061218993.gitgitgadget@gmail.com>
On Mon, Jul 15, 2024 at 04:33:38PM +0000, Matthew Hughes via GitGitGadget wrote:
Show 26 quoted lines
> diff --git a/userdiff.c b/userdiff.c
> index c4ebb9ff734..7247d351cde 100644
> --- a/userdiff.c
> +++ b/userdiff.c
> @@ -333,6 +333,17 @@ PATTERNS("scheme",
>  	 "|([^][)(}{[ \t])+"),
>  PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
>  	 "\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
> +PATTERNS("typescript",
> +	"^[\t ]*((class|constructor|public|private|protected|function|interface)[ \t].*)$\n"
> +	// arrow funcs
> +	"^[\t ]*((const|let|var)?[^()]*)=[\t ]*\\([^()]*\\)[\t ]*.*=>.*$",
> +	/* -- */
> +	"[a-zA-Z_][a-zA-Z0-9_]*"
> +	// numeric constants
> +	"|[-+0-9.e]+|0[xX]?[0-9a-fA-F]"
> +	// operators
> +	"|[-+*/<>%&^|=!]"
> +	"|--|\\+\\+|//=?|<<=?|>>?=?"),
>  { .name = "default", .binary = -1 },
>  };
>  #undef PATTERNS
> 
> base-commit: a7dae3bdc8b516d36f630b12bb01e853a667e0d9
> -- 
> gitgitgadget

This needs some updates. For the arrow function, definitions can cover multiple lines e.g.:

    const bar = (
        name: string
    ) => console.log(name)

The funcname pattern should also consider the `export` keyword, since both of the following are valid:

    export const bar = (
        name: string
    ) => console.log(name)
    export function foo() {}
Some docs: https://www.typescriptlang.org/docs/handbook/modules/reference.html#module-syntax
Previous: Matthew Hughes via GitGitGadgetNext: Junio C Hamano
Message 2 of 6 in “userdiff: add builtin diff driver for TypeScript language”
  1. userdiff: add builtin diff driver for TypeScript languageMatthew Hughes via GitGitGadget, Jul 15, 2024
  2. Matthew HughesJul 16, 2024
  3. Junio C HamanoJul 16, 2024
  4. Matthew HughesJul 16, 2024
  5. Junio C HamanoJul 16, 2024
  6. Johannes SixtJul 16, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.