Change:
run a command in the terminal, run , cursor is at the top of the buffer mentioned by we'd want it to initially be at the bottom
It would be great if there was the possibility of not changing the position of the cursor during the buffer update, preserving the position of the last access. I believe that this would help in identifying the beginning of the response of the last executed command.
Yes, the plan is to only set the initial position to be the bottom of the buffer if possible. Subsequently, we won't alter it
verify that: when you add content by running a command with or without shell integration enabled, the cursor is positioned at the bottom of the last command's output when you change the cursor position but do not change / add output, the cursor position is retained when you toggle in and out of the buffer
I'm about to merge a PR which fixes these issues. Can you pls test and confirm this is the behavior you'd want/ expect? I debated about landing the cursor on the prompt line (one line below), but don't think that would be useful.
I tested and confirmed that now the cursor always goes to the end of the accessibility buffer, regardless of the previous position. At the beginning of the tests I had the impression that the position of the cursor was affected by the size of the response of the executed command, but I could not confirm this.
what I experience on mac: focus the accessible buffer, the cursor is on the last line, move the cursor up, exit the accessible buffer, focus the accessible buffer, the cursor is above the last line where I had it focus the accessible buffer, the cursor is on the last line, exit the accessible buffer, run a command, focus the accessible buffer, the cursor is on the last line
It seems the behavior is the same in my linux environment. Every time I execute a command and access the accessible buffer, the cursor is always on the last line of the executed command response, even if before executing the command I move the cursor to another position.
This is working for me on Windows, macOS, and linux via WSL. I'm not sure why it's not working for you . Would it be possible to record a gif?

Discussion:
import { IXtermCore } from 'vs/workbench/contrib/terminal/browser/xterm-private'; import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper'; <del> import { DisposableStore } from 'vs/base/common/lifecycle'; </del> <ins> import { DisposableStore, IDisposable } from 'vs/base/common/lifecycle'; </ins> import { IEditorOptions } from 'vs/editor/common/config/editorOptions'; import { IShellIntegration, TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal'; import { ITerminalFont, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';

private _accessibleBuffer: HTMLElement; private _bufferEditor: CodeEditorWidget; private _editorContainer: HTMLElement; <ins> private _commandFinishedDisposable: IDisposable | undefined; private _refreshSelection: boolean = true; </ins> private _registered: boolean = false; <ins> private _lastContentLength: number = 0; </ins> private _font: ITerminalFont; constructor(

async focus(): Promise<void> { await this._updateBufferEditor(); <del> // Updates xterm's accessibleBufferActive property // such that mouse events do not cause the terminal buffer // to steal the focus this._accessibleBuffer.focus(); this._bufferEditor.focus(); </del> } private async _updateBufferEditor(): Promise<void> { <ins> const commandDetection = this._capabilities.get(TerminalCapability.CommandDetection); const fragment = !!commandDetection ? this._getShellIntegrationContent() : this._getAllContent(); const model = await this._getTextModel(URI.from({ scheme: ACCESSIBLE_BUFFER.Scheme, fragment })); if (model) { this._bufferEditor.setModel(model); } </ins> if (!this._registered) { <del> // Registration is delayed until focus so the capability has time to have been added </del> this.add(this._terminal.raw.registerBufferElementProvider({ provideBufferElements: () => this._editorContainer })); <ins> // When this is created, the element isn't yet attached so the dimensions are tiny this._bufferEditor.layout({ width: this._accessibleBuffer.clientWidth, height: this._accessibleBuffer.clientHeight }); </ins> this._registered = true; } <del> // When this is created, the element isn't yet attached so the dimensions are tiny this._bufferEditor.layout({ width: this._accessibleBuffer.clientWidth, height: this._accessibleBuffer.clientHeight }); const commandDetection = this._capabilities.has(TerminalCapability.CommandDetection); const fragment = commandDetection ? this._getShellIntegrationContent() : this._getAllContent(); const model = await this._getTextModel(URI.from({ scheme: ACCESSIBLE_BUFFER.Scheme, fragment })); if (model) { this._bufferEditor.setModel(model); </del> <ins> if (!this._commandFinishedDisposable && commandDetection) { this._commandFinishedDisposable = commandDetection.onCommandFinished(() => this._refreshSelection = true); this.add(this._commandFinishedDisposable); } if (this._lastContentLength !== fragment.length || this._refreshSelection) { let lineNumber = 1; const lineCount = model?.getLineCount(); if (lineCount && model) { lineNumber = commandDetection ? lineCount - 1 : lineCount > 2 ? lineCount - 2 : 1; } this._bufferEditor.setSelection({ startLineNumber: lineNumber, startColumn: 1, endLineNumber: lineNumber, endColumn: 1 }); this._bufferEditor.setScrollTop(this._bufferEditor.getScrollHeight()); this._refreshSelection = false; this._lastContentLength = fragment.length; </ins> } <ins> // Updates xterm's accessibleBufferActive property // such that mouse events do not cause the terminal buffer // to steal the focus this._accessibleBuffer.focus(); this._bufferEditor.focus(); </ins> } async _getTextModel(resource: URI): Promise<ITextModel | null> {

} const isWrapped = buffer.getLine(i + 1)?.isWrapped; currentLine += line.translateToString(!isWrapped); <del> if (!isWrapped || i === end - 1) { </del> <ins> if (currentLine && !isWrapped || i === end - 1) { </ins> lines.push(currentLine.replace(new RegExp(' ', 'g'), 'xA0')); currentLine = ''; }