mlxprs icon indicating copy to clipboard operation
mlxprs copied to clipboard

Would like to easily name buffers

Open damonfeldman opened this issue 4 years ago • 3 comments

mlxprs v 3.0.2 (mac)

Suggest allowing a one-line comment above the /* ml connection param block */ to be ignored, and still have the ml connection params parsed out of the multi-line comment.

VS Code uses the first line of a non-saved buffer as the tab title, so this would allow a short title

// DELETE ALL DATA!! (or whatever) /* mlxprs:settings ... */

workaround is to save all buffers so the file name displays as the tab title.

damonfeldman avatar Jun 08 '20 09:06 damonfeldman

one easy way to do this is to modify vscQueryParameterTools.ts to discard the first line and check again starting with the 2nd line if there is no config comment found on the first line. A change to the docs would also be needed to clarify the config comment can belong on the first or 2nd line.

export function parseQueryForOverrides(queryText: string, language: string): Record<string, any> { 
    ...
}

to be:

export function parseQueryForOverrides(queryText: string, language: string): Record<string, any> { 
    let overrides = parseQueryForOverridesFromFirstLine(queryText, language)
    if (Object.keys(overrides).length == 0) {  // try again using line 2 to allow single header comment line
        queryText = discardFirstLine(queryText);
        overrides = parseQueryForOverridesFromFirstLine(queryText, language);
    }
    return overrides
}

function parseQueryForOverridesFromFirstLine(queryText: string, language: string): Record<string, any> { 
    ... existing code in this non-exported private function ...
}

function discardFirstLine(lines: string) {
    return lines.substring(lines.indexOf("\n") + 1)
}

damonfeldman avatar Jun 08 '20 10:06 damonfeldman

I don’t understand what you’re trying to do, @damonfeldman. When you evaluate a query, you want the ability to specify a name in title of the tab under which the results show up?

jmakeig avatar Jun 08 '20 23:06 jmakeig

Exactly. I want to see the name of my buffers. I use the comment syntax because in any real dev environment you have many instances (test/staging) and each instance has many DBs (staging/final/jobs/modules). So you almost have to use the comment headers. This means that all executable buffers get a tab name of: "/*mlxprs:settings:"

The RFE is to allow named non-saved tabs. image

damonfeldman avatar Jul 02 '20 13:07 damonfeldman