<!doctype html>
< html class = "default no-js" lang = "zh-CN" >
< head >
< meta charset = "utf-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< title > TextDocument | VS Code API 中文文档< / title >
< meta name = "description" content = "VS Code API 是一系列你可以在 Visual Studio Code 扩展中调用的 JavaScript API, 这个站点列出了扩展开发者可以使用的所有 vscode api 中文文档,是 vscode 插件开发必备。" >
< meta name = "author" content = "洛竹" >
< meta name = "copyright" content = "洛竹" >
< meta property = "og:title" content = "Vscode Api 中文文档" / >
< meta property = "og:type" content = "docs" >
< meta property = "og:image" content = "https://code.visualstudio.com/favicon.ico" / >
< meta property = "og:url" content = "https://vscode-api-cn.js.org/index.html" >
< meta property = "og:site_name" content = "Vscode Api 中文文档" >
< meta property = "og:description" content = "VS Code API 是一系列你可以在 Visual Studio Code 扩展中调用的 JavaScript API, 这个站点列出了扩展开发者可以使用的所有 vscode api 中文文档,是 vscode 插件开发必备。" >
< meta property = "article:tag" content = "vscode api" >
< meta property = "article:tag" content = "vscode api 中文文档" >
< meta property = "article:tag" content = "vscode 插件" >
< meta property = "article:tag" content = "vscode 插件开发" >
< meta property = "article:tag" content = "vscode VS Code API 中文文档" >
< meta property = "article:tag" content = "vscode TextDocument" >
< meta name = "viewport" content = "width=device-width, initial-scale=1, viewport-fit=cover" >
< link rel = "shortcut icon" href = "https://code.visualstudio.com/favicon.ico" sizes = "128x128" >
< link rel = 'canonical' href = 'https://vscode-api-cn.js.org/interfaces/vscode.TextDocument.html' / >
< link rel = "stylesheet" href = "../assets/css/main.css" >
< script async src = "../assets/js/search.js" id = "search-script" > < / script >
< script async src = "https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7962287588031867" crossorigin = "anonymous" > < / script >
<!-- Google tag (gtag.js) -->
< script async src = "https://www.googletagmanager.com/gtag/js?id=G-T4TRRS1LB1" > < / script >
< script >
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-T4TRRS1LB1');
< / script >
< style >
.container-main {
padding-bottom: 50px;
}
< / style >
< / head >
< body >
< header >
< div class = "tsd-page-toolbar" >
< div class = "container" >
< div class = "table-wrap" >
< div class = "table-cell" id = "tsd-search" data-index = "../assets/js/search.json" data-base = ".." >
< div class = "field" >
< label for = "tsd-search-field" class = "tsd-widget search no-caption" > Search< / label >
< input id = "tsd-search-field" type = "text" / >
< / div >
< ul class = "results" >
< li class = "state loading" > Preparing search index...< / li >
< li class = "state failure" > The search index is not available< / li >
< / ul >
< a href = "../index.html" class = "title" > VS Code API 中文文档< / a >
< / div >
< div class = "table-cell" id = "tsd-widgets" >
< div id = "tsd-filter" >
< a href = "#" class = "tsd-widget options no-caption" data-toggle = "options" > Options< / a >
< div class = "tsd-filter-group" >
< div class = "tsd-select" id = "tsd-filter-visibility" >
< span class = "tsd-select-label" > All< / span >
< ul class = "tsd-select-list" >
< li data-value = "public" > Public< / li >
< li data-value = "protected" > Public/Protected< / li >
< li data-value = "private" class = "selected" > All< / li >
< / ul >
< / div >
< input type = "checkbox" id = "tsd-filter-inherited" checked / >
< label class = "tsd-widget" for = "tsd-filter-inherited" > Inherited< / label >
< input type = "checkbox" id = "tsd-filter-externals" checked / >
< label class = "tsd-widget" for = "tsd-filter-externals" > Externals< / label >
< / div >
< / div >
< a href = "#" class = "tsd-widget menu no-caption" data-toggle = "menu" > Menu< / a >
< / div >
< / div >
< / div >
< / div >
< div class = "tsd-page-title" >
< div class = "container" >
< ul class = "tsd-breadcrumb" >
< li >
< a href = "../modules.html" > VS Code API 中文文档< / a >
< / li >
< li >
< a href = "../modules/vscode.html" > vscode< / a >
< / li >
< li >
< a href = "vscode.TextDocument.html" > TextDocument< / a >
< / li >
< / ul >
< h1 > Interface TextDocument< / h1 >
< / div >
< / div >
< / header >
< div class = "container container-main" >
< div class = "row" >
< div class = "col-8 col-content" >
< div class = "TrafficApeAds" data-type = "728x90" > < / div >
< section class = "tsd-panel tsd-comment" >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 表示文本文档,例如源文件。文本文档有 < a href = "vscode.TextLine.html" > lines< / a > 和关于底层资源(如文件)的知识。< / p >
< / div >
< dl class = "tsd-comment-tags" >
< dt > maintainer< / dt >
< dd > < p > < a href = "https://youngjuning.js.org" class = "external" > @youngjuning< / a > < / p >
< / dd >
< / dl >
< / div >
< / section >
< section class = "tsd-panel tsd-hierarchy" >
< h3 > 层级< / h3 >
< ul class = "tsd-hierarchy" >
< li >
< span class = "target" > TextDocument< / span >
< / li >
< / ul >
< / section >
< section class = "tsd-panel-group tsd-index-group" >
< h2 > 索引< / h2 >
< section class = "tsd-panel tsd-index-panel" >
< div class = "tsd-index-content" >
< section class = "tsd-index-section " >
< h3 > Properties( 9) < / h3 >
< ul class = "tsd-index-list" >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#uri" class = "tsd-kind-icon" > uri< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#fileName" class = "tsd-kind-icon" > file< wbr > Name< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#isUntitled" class = "tsd-kind-icon" > is< wbr > Untitled< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#languageId" class = "tsd-kind-icon" > language< wbr > Id< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#version" class = "tsd-kind-icon" > version< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#isDirty" class = "tsd-kind-icon" > is< wbr > Dirty< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#isClosed" class = "tsd-kind-icon" > is< wbr > Closed< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#eol" class = "tsd-kind-icon" > eol< / a > < / li >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#lineCount" class = "tsd-kind-icon" > line< wbr > Count< / a > < / li >
< / ul >
< / section >
< section class = "tsd-index-section " >
< h3 > Methods( 8) < / h3 >
< ul class = "tsd-index-list" >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#save" class = "tsd-kind-icon" > save< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#lineAt" class = "tsd-kind-icon" > line< wbr > At< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#offsetAt" class = "tsd-kind-icon" > offset< wbr > At< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#positionAt" class = "tsd-kind-icon" > position< wbr > At< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#getText" class = "tsd-kind-icon" > get< wbr > Text< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#getWordRangeAtPosition" class = "tsd-kind-icon" > get< wbr > Word< wbr > Range< wbr > AtPosition< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#validateRange" class = "tsd-kind-icon" > validate< wbr > Range< / a > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < a href = "vscode.TextDocument.html#validatePosition" class = "tsd-kind-icon" > validate< wbr > Position< / a > < / li >
< / ul >
< / section >
< / div >
< / section >
< / section >
< section class = "tsd-panel-group tsd-member-group " >
< h2 > Properties( 9) < / h2 >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "uri" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > uri< / h3 >
< div class = "tsd-signature tsd-kind-icon" > uri< span class = "tsd-signature-symbol" > :< / span > < a href = "../classes/vscode.Uri.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Uri< / a > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L99" > vscode.d.ts:99< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 与此文档关联的 uri。< / p >
< / div >
< p > < em > 注意< / em > 大多数文档使用 < code > file< / code > -scheme, 这意味着它们是磁盘上的文件。但是, < strong > 并非< / strong > 所有文档都保存在磁盘上,
因此在尝试访问底层文件或磁盘上的兄弟文件之前,必须检查 < code > scheme< / code > 。< / p >
< dl class = "tsd-comment-tags" >
< dt > see< / dt >
< dd > < p > < a href = "vscode.FileSystemProvider.html" > FileSystemProvider< / a > < / p >
< / dd >
< dt > see< / dt >
< dd > < p > < a href = "vscode.TextDocumentContentProvider.html" > TextDocumentContentProvider< / a > < / p >
< / dd >
< / dl >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "fileName" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > file< wbr > Name< / h3 >
< div class = "tsd-signature tsd-kind-icon" > file< wbr > Name< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > string< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L105" > vscode.d.ts:105< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 与此文档关联的资源的文件系统路径。< a href = "vscode.TextDocument.html#uri" > TextDocument.uri.fsPath< / a > 的简写。
独立于 uri scheme。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "isUntitled" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > is< wbr > Untitled< / h3 >
< div class = "tsd-signature tsd-kind-icon" > is< wbr > Untitled< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > boolean< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L111" > vscode.d.ts:111< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 这个文档是否表示尚未保存的未命名文件。< em > 注意< / em > ,这并不意味着文档将被保存到磁盘上,
使用 < a href = "../classes/vscode.Uri.html#scheme" > < code > Uri.scheme< / code > < / a > 来找出文档将被 < a href = "vscode.FileSystemProvider.html" > saved< / a > 的位置,例如 < code > file< / code > 、< code > ftp< / code > 等。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "languageId" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > language< wbr > Id< / h3 >
< div class = "tsd-signature tsd-kind-icon" > language< wbr > Id< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > string< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L116" > vscode.d.ts:116< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 与此文档关联的语言的标识符。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "version" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > version< / h3 >
< div class = "tsd-signature tsd-kind-icon" > version< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > number< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L121" > vscode.d.ts:121< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 此文档的版本号(每次更改后都会严格增加,包括撤消/重做)。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "isDirty" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > is< wbr > Dirty< / h3 >
< div class = "tsd-signature tsd-kind-icon" > is< wbr > Dirty< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > boolean< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L126" > vscode.d.ts:126< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 如果有未持久化的更改则为 < code > true< / code > 。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "isClosed" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > is< wbr > Closed< / h3 >
< div class = "tsd-signature tsd-kind-icon" > is< wbr > Closed< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > boolean< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L131" > vscode.d.ts:131< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 如果文档已关闭,则为 < code > true< / code > 。已关闭的文档不再同步,并且当再次打开相同的资源时,不会复用它。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "eol" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > eol< / h3 >
< div class = "tsd-signature tsd-kind-icon" > eol< span class = "tsd-signature-symbol" > :< / span > < a href = "../enums/vscode.EndOfLine.html" class = "tsd-signature-type" data-tsd-kind = "Enumeration" > EndOfLine< / a > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L143" > vscode.d.ts:143< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 这个文档中主要使用的 < a href = "../enums/vscode.EndOfLine.html" > end of line< / a > 序列。< / p >
< / div >
< / div >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-property tsd-parent-kind-interface" >
< a name = "lineCount" class = "tsd-anchor" > < / a >
< h3 > < span class = "tsd-flag ts-flagReadonly" > Readonly< / span > line< wbr > Count< / h3 >
< div class = "tsd-signature tsd-kind-icon" > line< wbr > Count< span class = "tsd-signature-symbol" > :< / span > < span class = "tsd-signature-type" > number< / span > < / div >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L148" > vscode.d.ts:148< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 这个文档中的行数。< / p >
< / div >
< / div >
< / section >
< / section >
< section class = "tsd-panel-group tsd-member-group " >
< h2 > Methods( 8) < / h2 >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "save" class = "tsd-anchor" > < / a >
< h3 > save< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > save< span class = "tsd-signature-symbol" > (< / span > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < a href = "Thenable.html" class = "tsd-signature-type" data-tsd-kind = "Interface" > Thenable< / a > < span class = "tsd-signature-symbol" > < < / span > < span class = "tsd-signature-type" > boolean< / span > < span class = "tsd-signature-symbol" > > < / span > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L138" > vscode.d.ts:138< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 保存底层文件。< / p >
< / div >
< / div >
< h4 class = "tsd-returns-title" > Returns < a href = "Thenable.html" class = "tsd-signature-type" data-tsd-kind = "Interface" > Thenable< / a > < span class = "tsd-signature-symbol" > < < / span > < span class = "tsd-signature-type" > boolean< / span > < span class = "tsd-signature-symbol" > > < / span > < / h4 >
< p > 一个 promise, 当文件保存时会 resolve 为 < code > true< / code > 。如果文件没有被修改或保存失败,则会返回 < code > false< / code > 。< / p >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "lineAt" class = "tsd-anchor" > < / a >
< h3 > line< wbr > At< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > line< wbr > At< span class = "tsd-signature-symbol" > (< / span > line< span class = "tsd-signature-symbol" > : < / span > < span class = "tsd-signature-type" > number< / span > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < a href = "vscode.TextLine.html" class = "tsd-signature-type" data-tsd-kind = "Interface" > TextLine< / a > < / li >
< li class = "tsd-signature tsd-kind-icon" > line< wbr > At< span class = "tsd-signature-symbol" > (< / span > position< span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < a href = "vscode.TextLine.html" class = "tsd-signature-type" data-tsd-kind = "Interface" > TextLine< / a > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L156" > vscode.d.ts:156< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 返回由行号表示的文本行。请注意,返回的对象< em > 不是< / em > 实时的,对文档的更改不会反映在其中。< / p >
< / div >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > line: < span class = "tsd-signature-type" > number< / span > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 行号 [0, lineCount)。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < a href = "vscode.TextLine.html" class = "tsd-signature-type" data-tsd-kind = "Interface" > TextLine< / a > < / h4 >
< p > 一个 < a href = "vscode.TextLine.html" > line< / a > 。< / p >
< / li >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L168" > vscode.d.ts:168< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 返回由位置表示的文本行。请注意,返回的对象< em > 不是< / em > 实时的,对文档的更改不会反映在其中。< / p >
< / div >
< p > 位置将被 < a href = "vscode.TextDocument.html#validatePosition" > adjusted< / a > 。< / p >
< dl class = "tsd-comment-tags" >
< dt > see< / dt >
< dd > < p > < a href = "vscode.TextDocument.html#lineAt" > TextDocument.lineAt< / a > < / p >
< / dd >
< / dl >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > position: < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 一个位置。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < a href = "vscode.TextLine.html" class = "tsd-signature-type" data-tsd-kind = "Interface" > TextLine< / a > < / h4 >
< p > 一个 < a href = "vscode.TextLine.html" > line< / a > 。< / p >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "offsetAt" class = "tsd-anchor" > < / a >
< h3 > offset< wbr > At< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > offset< wbr > At< span class = "tsd-signature-symbol" > (< / span > position< span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < span class = "tsd-signature-type" > number< / span > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L178" > vscode.d.ts:178< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 将位置转换为基于 0 的偏移量。< / p >
< / div >
< p > 位置将被 < a href = "vscode.TextDocument.html#validatePosition" > adjusted< / a > 。< / p >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > position: < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 一个位置。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < span class = "tsd-signature-type" > number< / span > < / h4 >
< p > 一个有效的基于 0 的偏移量。< / p >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "positionAt" class = "tsd-anchor" > < / a >
< h3 > position< wbr > At< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > position< wbr > At< span class = "tsd-signature-symbol" > (< / span > offset< span class = "tsd-signature-symbol" > : < / span > < span class = "tsd-signature-type" > number< / span > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L186" > vscode.d.ts:186< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 将基于 0 的偏移量转换为位置。< / p >
< / div >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > offset: < span class = "tsd-signature-type" > number< / span > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 一个基于 0 的偏移量。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / h4 >
< p > 一个有效的 < a href = "../classes/vscode.Position.html" > Position< / a > 。< / p >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "getText" class = "tsd-anchor" > < / a >
< h3 > get< wbr > Text< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > get< wbr > Text< span class = "tsd-signature-symbol" > (< / span > range< span class = "tsd-signature-symbol" > ?: < / span > < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < span class = "tsd-signature-type" > string< / span > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L191" > vscode.d.ts:191< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 获取此文档的文本。可以通过提供范围来检索子字符串。范围将被 < a href = "vscode.TextDocument.html#validateRange" > adjusted< / a > 。< / p >
< / div >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > < span class = "tsd-flag ts-flagOptional" > Optional< / span > range: < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < / h5 >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < span class = "tsd-signature-type" > string< / span > < / h4 >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "getWordRangeAtPosition" class = "tsd-anchor" > < / a >
< h3 > get< wbr > Word< wbr > Range< wbr > AtPosition< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > get< wbr > Word< wbr > Range< wbr > AtPosition< span class = "tsd-signature-symbol" > (< / span > position< span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > , regex< span class = "tsd-signature-symbol" > ?: < / span > < span class = "tsd-signature-type" > RegExp< / span > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < span class = "tsd-signature-type" > undefined< / span > < span class = "tsd-signature-symbol" > | < / span > < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L207" > vscode.d.ts:207< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 获取给定位置的单词范围。默认情况下,单词由常见分隔符定义,例如空格、-、_ 等。
此外,可以定义每种语言的自定义 [单词定义]。还可以提供自定义正则表达式。< / p >
< / div >
< ul >
< li > < p > < em > 注意 1:< / em > 自定义正则表达式不得匹配空字符串,如果它这样做了,它将被忽略。< / p >
< / li >
< li > < p > < em > 注意 2:< / em > 自定义正则表达式将无法匹配多行字符串,为了速度,正则表达式不应该匹配带有空格的单词。使用 < a href = "vscode.TextLine.html#text" > < code > TextLine.text< / code > < / a > 以获取更复杂、非单词的场景。< / p >
< / li >
< / ul >
< p > 位置将被 < a href = "vscode.TextDocument.html#validatePosition" > adjusted< / a > 。< / p >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > position: < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 一个位置。< / p >
< / div >
< / li >
< li >
< h5 > < span class = "tsd-flag ts-flagOptional" > Optional< / span > regex: < span class = "tsd-signature-type" > RegExp< / span > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 可选的正则表达式,描述了单词是什么。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < span class = "tsd-signature-type" > undefined< / span > < span class = "tsd-signature-symbol" > | < / span > < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < / h4 >
< p > 一个范围,包含一个单词,或 < code > undefined< / code > 。< / p >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "validateRange" class = "tsd-anchor" > < / a >
< h3 > validate< wbr > Range< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > validate< wbr > Range< span class = "tsd-signature-symbol" > (< / span > range< span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L215" > vscode.d.ts:215< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 确保范围完全包含在此文档中。< / p >
< / div >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > range: < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 一个范围。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < a href = "../classes/vscode.Range.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Range< / a > < / h4 >
< p > 给定的范围或一个新的、调整过的范围。< / p >
< / li >
< / ul >
< / section >
< section class = "tsd-panel tsd-member tsd-kind-method tsd-parent-kind-interface" >
< a name = "validatePosition" class = "tsd-anchor" > < / a >
< h3 > validate< wbr > Position< / h3 >
< ul class = "tsd-signatures tsd-kind-method tsd-parent-kind-interface" >
< li class = "tsd-signature tsd-kind-icon" > validate< wbr > Position< span class = "tsd-signature-symbol" > (< / span > position< span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < span class = "tsd-signature-symbol" > )< / span > < span class = "tsd-signature-symbol" > : < / span > < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / li >
< / ul >
< ul class = "tsd-descriptions" >
< li class = "tsd-description" >
< aside class = "tsd-sources" >
< ul >
< li > Defined in < a href = "https://github.com/youngjuning/vscode-api-cn.js.org/blob/bbec0ea/vscode.d.ts#L223" > vscode.d.ts:223< / a > < / li >
< / ul >
< / aside >
< div class = "tsd-comment tsd-typography" >
< div class = "lead" >
< p > 确保位置包含在此文档的范围内。< / p >
< / div >
< / div >
< h4 class = "tsd-parameters-title" > Parameters< / h4 >
< ul class = "tsd-parameters" >
< li >
< h5 > position: < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / h5 >
< div class = "tsd-comment tsd-typography" >
< p > 一个位置。< / p >
< / div >
< / li >
< / ul >
< h4 class = "tsd-returns-title" > Returns < a href = "../classes/vscode.Position.html" class = "tsd-signature-type" data-tsd-kind = "Class" > Position< / a > < / h4 >
< p > 给定的位置或一个新的、调整过的位置。< / p >
< / li >
< / ul >
< / section >
< / section >
< div class = "tsd-panel tsd-typography" >
< ins class = "adsbygoogle" style = "display:block" data-ad-format = "autorelaxed" data-ad-client = "ca-pub-7962287588031867"
data-ad-slot="3578139931">< / ins >
< script > ( adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ; < / script >
< / div >
< / div >
< div class = "col-4 col-menu menu-sticky-wrap menu-highlight" >
< nav class = "tsd-navigation primary" >
< ul >
< li class = " " >
< a href = "../modules.html" > Exports< / a >
< / li >
< li class = "current tsd-kind-namespace" >
< a href = "../modules/vscode.html" > vscode< / a >
< ul >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.authentication.html" > authentication< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.commands.html" > commands< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.comments.html" > comments< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.debug.html" > debug< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.env.html" > env< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.extensions.html" > extensions< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.languages.html" > languages< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.notebooks.html" > notebooks< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.scm.html" > scm< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.tasks.html" > tasks< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.tests.html" > tests< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.window.html" > window< / a >
< / li >
< li class = " tsd-kind-namespace tsd-parent-kind-namespace" >
< a href = "../modules/vscode.workspace.html" > workspace< / a >
< / li >
< / ul >
< / li >
< / ul >
< / nav >
< nav class = "tsd-navigation secondary menu-sticky" >
< div style = "width: 200px" >
< script async = "async" type = "text/javascript" id = "clstr_globe" src = "//clustrmaps.com/globe.js?d=cMnk-gSDNcAzNMMm67U8rWRaHnjUc0Xb0giSGndepK4" > < / script >
< / div >
< ul class = "before-current" >
< / ul >
< ul class = "current" >
< li class = "current tsd-kind-interface tsd-parent-kind-namespace" >
< a href = "vscode.TextDocument.html" class = "tsd-kind-icon" > Text< wbr > Document< / a >
< ul >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#uri" class = "tsd-kind-icon" > uri< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#fileName" class = "tsd-kind-icon" > file< wbr > Name< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#isUntitled" class = "tsd-kind-icon" > is< wbr > Untitled< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#languageId" class = "tsd-kind-icon" > language< wbr > Id< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#version" class = "tsd-kind-icon" > version< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#isDirty" class = "tsd-kind-icon" > is< wbr > Dirty< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#isClosed" class = "tsd-kind-icon" > is< wbr > Closed< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#save" class = "tsd-kind-icon" > save< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#eol" class = "tsd-kind-icon" > eol< / a >
< / li >
< li class = " tsd-kind-property tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#lineCount" class = "tsd-kind-icon" > line< wbr > Count< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#lineAt" class = "tsd-kind-icon" > line< wbr > At< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#offsetAt" class = "tsd-kind-icon" > offset< wbr > At< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#positionAt" class = "tsd-kind-icon" > position< wbr > At< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#getText" class = "tsd-kind-icon" > get< wbr > Text< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#getWordRangeAtPosition" class = "tsd-kind-icon" > get< wbr > Word< wbr > Range< wbr > AtPosition< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#validateRange" class = "tsd-kind-icon" > validate< wbr > Range< / a >
< / li >
< li class = " tsd-kind-method tsd-parent-kind-interface" >
< a href = "vscode.TextDocument.html#validatePosition" class = "tsd-kind-icon" > validate< wbr > Position< / a >
< / li >
< / ul >
< / li >
< / ul >
< ul class = "after-current" >
< / ul >
< / nav >
< / div >
< / div >
< / div >
< footer class = "with-border-bottom" >
< div class = "container" >
< h2 > 图例< / h2 >
< div class = "tsd-legend-group" >
< ul class = "tsd-legend" >
< li class = "tsd-kind-property tsd-parent-kind-interface" > < span class = "tsd-kind-icon" > Property< / span > < / li >
< li class = "tsd-kind-method tsd-parent-kind-interface" > < span class = "tsd-kind-icon" > Method< / span > < / li >
< / ul >
< / div >
< / div >
< / footer >
< div class = "container tsd-generator" >
< p > 友链:< a href = "https://jeasonstudio.gitbooks.io/vscode-cn-doc/content/" target = "_blank" > VS Code 中文文档< / a > | < a href = "https://code.visualstudio.com/docs" target = "_blank" > VS Code 官网文档< / a > | < a href = "https://marketplace.visualstudio.com/" target = "_blank" > VS Code 扩展市场< / a > < / p >
< p > Generated by < a href = "https://typedoc.org/" target = "_blank" > TypeDoc< / a > . Maintained by < a href = "https://youngjuning.js.org" target = "_blank" > 洛竹< / a > < / p >
< / div >
< div class = "overlay" > < / div >
< script src = "../assets/js/main.js" > < / script >
< script src = "https://az622064.vo.msecnd.net/scripts/apeads.js?key=0dfb2336-346c-4062-be08-a633e5229abe" > < / script >
< / body >
< / html >